Introduction
Hello world, I'm new to Objective C and I have been experimenting with the PageViewController
. One problem I have encountered while making this app is changing the action of a button depending on the PageViewController
. I have approached the situation in a multitude of ways.
Situation
I was trying to make a PageViewController
to help a player choose a theme for a game, but in order to do this I need to figure out the answer to this question. I followed this tutorial except I got rid of the startWalkthrough
button as it was unnecessary and I changed the self.pageViewController.view = CGRectMake(0, 100, self.view.frame.size.width, self.view.frame.size.height - 200);
as well as changing the NSArray _pageTitles = @[@"Theme 1", @"Theme 2", @"Theme 3", @"Theme 4"];
on the main view controller to allow more space for buttons and such.
I made a new button (chooseButton
) and a label (themeTitles
) just as an example to check whether or not the app realized which theme it was on the main view controller. I tried to use the following lines of code:
- (IBAction)chooseButton:(id)sender {
if () {
_themeTitles.text = @"You chose theme 1";
}
if () {
_themeTitles.text = @"You chose theme 2";
}
if () {
_themeTitles.text = @"You chose theme 3";
}
if () {
_themeTitles.text = @"You chose theme 4";
}
}
You may notice that the condition is blank. This is the part where I have tried a variety of things. This may include using properties from other header files, or properties declared in its own header file such as declaring PageContentViewController *pageContentViewController;
and then saying if (pageContentViewController.pageIndex == 0)
and so on until it equals 3, or saying if (pageContentViewController.titleText isEqual: @"Theme 1")
.
I also tried declaring AppDelegate *appDelegate;
after importing it of course and making the UIPageControl
public as a property and also making a currentPage
property to say if (AppDelegate.pageControl.currentPage == 0)
and so on.
I am going mad exhausting every option while they all end up displaying "You chose theme 1" on the interface for every current page it is on or it doesn't display anything at all.
Ultimately, the point is, what condition can I put in the if statement to get this thing working?