Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create an enum like style in WatchPreviewViewController and create your own init method.</p> <pre> typedef enum WatchPreviewViewControllerStyleType { WatchPreviewViewControllerStyleType1 = 0, WatchPreviewViewControllerStyleType2 = 1 }WatchPreviewViewControllerStyleType; @interface WatchPreviewViewController : UIViewController { WatchPreviewViewControllerStyleType style; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andStyle:(WatchPreviewViewControllerStyleType)_style; </pre> <pre> @implementation - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andStyle:(WatchPreviewViewControllerStyleType)_style { self.style=_style; } - (void)viewDidLoad { [super viewDidLoad]; if(self.style==WatchPreviewViewControllerStyleType1) { } else if(self.style==WatchPreviewViewControllerStyleType2) { } } </pre> <p>in this custom init set the ivar style sent while creating the controller. and then in viewDidload check for the style type and add the required views for that style.</p> <p>and in WatchViewController</p> <pre> @implementation WatchViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *watch1 = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; watch1.tag=123; watch1.frame = CGRectMake(5.0, 10.0, 140.0, 170.0); [watch1 setBackgroundImage:[UIImage imageNamed:@"Watch1.png"] forState: UIControlStateNormal]; [watch1 addTarget:self action:@selector(WatchesPreviewButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [scr addSubview:watch1]; UIButton *watch2 = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; watch1.tag=456; watch2.frame = CGRectMake(170.0, 10.0, 140.0, 170.0); [watch2 setBackgroundImage:[UIImage imageNamed:@"watch2.png"] forState: UIControlStateNormal]; [watch2 addTarget:self action:@selector(WatchesPreviewButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [scr addSubview:watch2]; } - (IBAction)WatchesPreviewButtonPressed:(id)sender { if(sender.tag==123) { WatchPreviewViewController *watchesPreviewView = [[WatchPreviewViewController alloc] initWithNibName:@"WatchPreviewViewController" bundle:nil andStyle:WatchPreviewViewControllerStyleType1]; [self.navigationController pushViewController:watchesPreviewView animated:YES]; [watchesPreviewView release]; } else { WatchPreviewViewController *watchesPreviewView = [[WatchPreviewViewController alloc] initWithNibName:@"WatchPreviewViewController" bundle:nil andStyle:WatchPreviewViewControllerStyleType2] ; [self.navigationController pushViewController:watchesPreviewView animated:YES]; [watchesPreviewView release]; } } </pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload