選択項目はスライダーです。スライダーをクリックすると、データがSecond VC(WebViewController)に渡されます。最初のビューコントローラからのデータを目的のcで2番目のビューコントローラに渡す方法はありますか?申し訳ありませんが、これは客観C.目的のビューコントローラ間でデータを渡す方法-c?
まずVCの.mファイル
#import "WebViewController.h"
- (void)viewDidLoad {
[super viewDidLoad];
arraySliderProducts = [[NSMutableArray alloc]init];
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
UIViewController *controller = nil;
switch (indexPath.row)
{
case 0:
{
WebViewController *WebViewController = [[WebViewController alloc] init];
//error: No visible @interface for "WebViewController" declares the selector 'alloc'
WebViewController.data = arraySliderProducts[indexPath.row][@"title"]; //pass this link value
//error: Property 'data' not found on object of type 'WebViewController'
[self.navigationController pushViewController: WebViewController animated:YES];
}..
セカンドVCの.mファイル
@interface WebViewController()
@property (nonatomic, retain) NSString *data;
セカンドVC .hファイル
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController
{
AppDelegate *appDelegate;
NSString *data;
}
@end
NSString *データを追加しようとしています。内部または外部の@interface .hファイル。それでもエラーが発生します。 –
このエラーは通常、オブジェクトの作成が許可されていないオブジェクトを作成すると発生します。 –
あなたの2番目のvc '.h'ファイルコードを表示します –