I have added UINavigationBar in appDelegate method. Please check my atatched screen shots. In bottom is i have used UINavigationBar. In middel of the page history button is there.
Here when i click the history button its cant go to historyviwcontrooler. Because i cant push the view. Can you please tell me how i can push here. When i click history its called only one calls after only thet called another class there only i given UI. How i handel here . please help me
#import "UICallButton.h"
#import "LinphoneManager.h"
#import <CoreTelephony/CTCallCenter.h>
#implementation UICallButton
#synthesize addressField;
#pragma mark - Lifecycle Functions
- (void)initUICallButton {
[self addTarget:self action:#selector(touchUp:) forControlEvents:UIControlEventTouchUpInside];
}
- (id)init {
self = [super init];
if (self) {
[self initUICallButton];
}
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initUICallButton];
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (self) {
[self initUICallButton];
}
return self;
}
- (void)dealloc {
[addressField release];
[super dealloc];
}
#pragma mark -
- (void)touchUp:(id) sender {
NSString *address = [addressField text];
NSString *displayName = nil;
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:address];
if(contact) {
displayName = [FastAddressBook getContactDisplayName:contact];
}
[[LinphoneManager instance] call:address displayName:displayName transfer:FALSE];
}
#end
Basically, you must have a UINavigationController, and not just a UINavigationBar, in order to be able to perform a push transition to one UIViewController to another.
I'm not explaining how to do that because it's very basic, you should study and read some books/tutorials before begin a real project.
Here's some links to help you:
A nice tutorial
How to use navigation controllers (from apple)
Navigation Controller class reference
Related
I have a UIViewController called TestViewController.h/.m:
Header file has:
#property (nonatomic, assign) BOOL isTested;
Implementation file has:
#implementation TestViewController
- (void)viewDidLoad
{
if (_isTested)
{
[self postNotification];
[self listenToNotifications];
}
}
I have a view that has this:
- (void) replyTapPressed
{
TestViewController *test = [[TestViewController alloc] init];
test.isTested = NO;
[_parent.navigationController pushViewController:test animated:YES];
}
Through the app's life cycle, the TestViewController's property starts off as YES; but when the view about gets called, it should set the property to NO; - which it does.
But _parent (which is the parent UIViewController) and test are both NULL.
Am I initializing and implementing it wrong?
Thanks.
You may try in below ways -
TestViewController.m
- (id)initWithTested:(BOOL)value
{
if (self = [super init])
{
self.isTested = value;
}
return self;
}
- (void) replyTapPressed
{
TestViewController *test = [[TestViewController alloc] initWithTested:NO];
[_parent.navigationController pushViewController:test animated:YES];
}
The view will "load" during initialization of your controller. To achieve what you want, implement viewWillAppear and move
if (_isTested) {
[self postNotification];
[self listenToNotifications];
}
there. (You could also put this in viewDidAppear, depending on what you are doing.)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Any help will be appreciated, I've been stuck on this for quite a while. i added content to my UITableView and reload the data nothing happens and I cant quite figure out whats going on with my parkinglistviewcontroller. Well here's my code that I'm using.
.m File
#implementation ParkingListViewController
#synthesize objCustomCell;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
arrParkingList = [[NSMutableArray alloc] init];
appDelegate = [[UIApplication sharedApplication] delegate];
locationManager = [[CLLocationManager alloc] init];
arrAnnotations = [[NSMutableArray alloc] init];
// Do any additional setup after loading the view from its nib.
}
-(void)viewWillAppear:(BOOL)animated
{
[self locate];
[parkingMap setRegion:MKCoordinateRegionMakeWithDistance(parkingMap.userLocation.coordinate, 5, 5) animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc
{
[locationManager release];
[tblParkingList release];
[parkingMap release];
[super dealloc];
}
- (void)viewDidUnload
{
[tblParkingList release];
tblParkingList = nil;
[parkingMap release];
parkingMap = nil;
[super viewDidUnload];
}
#pragma mark - Tableview Methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return arrParkingList.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ParkingCustomCell *cell = (ParkingCustomCell*)[tableView dequeueReusableCellWithIdentifier:#"CellIdentifier"];
if (cell == nil)
{
[[NSBundle mainBundle] loadNibNamed:#"ParkingCustomCell" owner:self options:nil];
cell = self.objCustomCell;
self.objCustomCell = nil;
}
ClsParking *objTmpParking = [arrParkingList objectAtIndex:indexPath.row];
cell.lblTitle.text = objTmpParking.strLocation;
cell.imgUserImage.layer.masksToBounds = YES;
cell.imgUserImage.layer.cornerRadius = 20;
[cell.imgUserImage setImageWithURL:[NSURL URLWithString:objTmpParking.strImageUrl] placeholderImage:nil];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 68;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ClsParking *objParking = [arrParkingList objectAtIndex:indexPath.row];
float fltLatitude = [objParking.strLatitude floatValue];
float fltLongitude = [objParking.strLongitude floatValue];
CLLocationCoordinate2D pLocation = CLLocationCoordinate2DMake(fltLatitude, fltLongitude);
[self setMapCenter:pLocation];
}
- (IBAction)btnAddTapped:(id)sender
{
ParkingNotificationViewController *objParkingNotificationViewController =[[ParkingNotificationViewController alloc] initWithNibName:#"ParkingNotificationViewController" bundle:nil];
[self presentViewController:objParkingNotificationViewController animated:YES completion:nil];
[objParkingNotificationViewController release];
}
- (IBAction)btnBackTapped:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
#end
.h file
#class ParkingCustomCell;
#interface ParkingListViewController : UIViewController <UITableViewDataSource,UITableViewDelegate,CLLocationManagerDelegate,MKMapViewDelegate>
{
IBOutlet UITableView *tblParkingList;
NSMutableArray *arrParkingList;
AppDelegate *appDelegate;
CLLocationManager *locationManager;
IBOutlet MKMapView *parkingMap;
NSMutableArray *arrAnnotations;
}
#property (nonatomic,retain) IBOutlet ParkingCustomCell *objCustomCell;
- (IBAction)btnAddTapped:(id)sender;
- (IBAction)btnBackTapped:(id)sender;
#end
And here's my parkingcustomcell class
#implementation ParkingCustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc {
[_lblTitle release];
[_imgUserImage release];
[super dealloc];
}
#end
In viewdidload method add the following :
self. tblParkingList.delegate = self;
self. tblParkingList.delegate = self;
Also #synthesize tblParkingList;
After that you have initialised an array arrParkingList for populating the table.Add content to it because it is empty.
In addition to AdamG's comment, I see you have allocated space for arrParkingList array, but I can't see where you add values to it/initialize it.
You should make sure that you set the class as the delegate for the tableview and the datasource delegate for the tableview. You can do this in the storyboarding by control dragging from the tableView to the icon on the left hand side of the bar, or by adding the following lines of code to your app..
self.tableView.delegate = self;
self.tableView.dataSource = self;
Also make sure that your tableView is declared as an outlet in your .h file. I am assuming you dragged it as an outlet called "tableView" in the above example.
Hope that helps!
So, I think that when I click outside of a popover, the method popoverControllerDidDismissPopover should be called. I know this isn't called when dismissPopoverAnimated is called.
I have a simple project that I have setup that shows popoverControllerDidDismissPopover just isn't called:
#import "ViewController.h"
#import "PopoverViewController.h"
#interface ViewController ()
{
PopoverViewController *controller;
UIPopoverController *popoverController;
}
#end
#implementation ViewController
#synthesize button;
- (IBAction)showPopover:(UIButton *)sender
{
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
} else {
CGRect popRect = CGRectMake(self.button.frame.origin.x,
self.button.frame.origin.y,
self.button.frame.size.width,
self.button.frame.size.height);
[popoverController presentPopoverFromRect:popRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
controller = [[PopoverViewController alloc] initWithNibName:#"PopoverViewController" bundle:nil];
popoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
NSLog(#"Why am I never called!!!!");
}
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
return true;
}
#end
Please tell me where I'm going wrong or how I can detect when a popover is dismissed.
The whole project is here:
https://rapidshare.com/files/3182903825/PopoverDemo.zip
You never set the delegate for your popoverController to self.
_popoverController.delegate = self;
You didn't set the delegate of your popoverController. Add the following code to the end of the viewDidLoad method:
popoverController.delegate = self;
pass data from FirstViewController to DetailViewController. i can not set the text of label in DetailViewController; FirstViewController is a tableview and it is good.
i use method updateRowNumber to set the rowNumber . and in DetailViewController, i can use debugger to see the rowNumber is correct. but the label's text is not showed on the view.
anyone can help me out?
in my FirstViewController
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (dvController == nil)
{
DetailViewController *aController = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
self.dvController = aController;
[aController release];
}
[[self navigationController] pushViewController:dvController animated:YES];
[dvController updateRowNumber:indexPath.row];
}
in my DetailViewController.h
#import <UIKit/UIKit.h>
#interface DetailViewController : UIViewController
{
int rowNumber;
IBOutlet UILabel *message;
}
#property(readwrite) int rowNumber;
#property(nonatomic, retain) IBOutlet UILabel *message;
- (void) updateRowNumber:(int) theindex;
#end
in my DetailViewController.m
#import "DetailViewController.h"
#interface DetailViewController ()
#end
#implementation DetailViewController
#synthesize message, rowNumber;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void) updateRowNumber: (int) theindex
{
rowNumber = theindex + 1;
message.text = [NSString stringWithFormat:#"row %i was clicked", rowNumber];
}
- (void)dealloc
{
[message release];
[super dealloc];
}
- (void)viewDidLoad
{
message.text = [NSString stringWithFormat:#"row %i was clicked ", rowNumber];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Do any additional setup after loading the view from its nib.
}
- (void)viewWillAppear:(BOOL)animated
{
//message.text = [NSString stringWithFormat:#"row %i was clicked ", rowNumber];
[super viewWillAppear: animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear: animated];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#end
You'll need to learn how the view is loaded, the process is well described in the documentation
What happens is that the view and all the outlets are nil until the view is loaded, you can make sure it is loaded by calling self.view; before configuring the outlet at updateRowNumber:
Please also note, you are better to call [super viewDidLoad] in the beginning of the overridden viewDidLoad, it makes sense as you need to let UIViewContorller to do it's staff before you do some customized logic, the dealloc is different as you need to do your logic before the standard NSObject -dealloc fires. Hope it's understandable.
I'm trying to implement UIScrollView with UIPageControl on storyboard to display multiple views. All the examples, tutorials or informations I found are using xib and not storyboard. I tried to adapt Apple's sample code but I'm missing something. As you can see, it is quite simple.
However, either I get an error in ContentController.m -[NSNull view]: unrecognized selector sent to instance 0x129acd8 when I test if (controller.view.superview == nil) where I push the view (see below after the first half of code).
Or only the UIScrollView and UIPageControl are working and I am not able to push the view in the UIScrollView:
I know it's a simple question, however I spent many hours on this and any help will be appreciated.
I post the full code as it may help someone when resolved like a kind of tutorial. I will correct the code if/when needed according to contributions.
Thanks in advance
AppDelegate.h
// Nothing special as I don't want to manage it through application delegate
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
AppDelegate.m
// Nothing special as I don't want to manage it through application delegate
#import "AppDelegate.h"
#implementation AppDelegate
#synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application { }
- (void)applicationDidEnterBackground:(UIApplication *)application { }
- (void)applicationWillEnterForeground:(UIApplication *)application { }
- (void)applicationDidBecomeActive:(UIApplication *)application { }
- (void)applicationWillTerminate:(UIApplication *)application { }
#end
ContentController.h
// From Apple's PageControl sample code
#import <UIKit/UIKit.h>
#interface ContentController : UIViewController <UIScrollViewDelegate> {
UIScrollView *scrollView;
UIPageControl *pageControl;
NSMutableArray *viewControllers;
BOOL pageControlUsed;
}
#property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
#property (nonatomic, retain) IBOutlet UIPageControl *pageControl;
#property (nonatomic, retain) NSMutableArray *viewControllers;
- (IBAction)changePage:(id)sender;
#end
ContentController.m
// From Apple's PageControl sample code
#import "AppDelegate.h"
#import "ContentController.h"
#import "MyViewController.h"
// Private methods
#interface ContentController (PrivateMethods)
- (void)loadScrollViewWithPage:(int)page;
- (void)scrollViewDidScroll:(UIScrollView *)sender;
#end
#implementation ContentController
#synthesize scrollView, pageControl, viewControllers;
static NSUInteger kNumberOfPages = 6;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.navigationController.navigationBar.hidden=YES;
// view controllers are created lazily in the meantime, load the array with
// placeholders which will be replaced on demand
NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned i = 0; i < kNumberOfPages; i++) {
[controllers addObject:[NSNull null]];
}
self.viewControllers = controllers;
// a page is the width of the scroll view
scrollView.pagingEnabled = YES;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height);
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop = NO;
scrollView.delegate = self;
pageControl.numberOfPages = kNumberOfPages;
pageControl.currentPage = 0;
// pages are created on demand
// load the visible page
// load the page on either side to avoid flashes when the user starts scrolling
[self loadScrollViewWithPage:0];
[self loadScrollViewWithPage:1];
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.pageControl=nil;
self.pageControl = nil;
self.viewControllers = nil;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)loadScrollViewWithPage:(int)page {
if (page < 0)
return;
if (page >= kNumberOfPages)
return;
// replace the placeholder if necessary
MyViewController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null]) // <== *** HERE SEEMS TO BE THE ERROR ***
{
controller = [[MyViewController alloc] initWithPageNumber:page
initWithNibName:nil
bundle:nil];
[viewControllers replaceObjectAtIndex:page withObject:controller];
}
// add the controller's view to the scroll view
if (controller.view.superview == nil)
{
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scrollView addSubview:controller.view];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)sender {
// We don't want a "feedback loop" between the UIPageControl and the scroll delegate in
// which a scroll event generated from the user hitting the page control triggers updates from
// the delegate method. We use a boolean to disable the delegate logic when the page control is used.
if (pageControlUsed) {
// do nothing - the scroll was initiated from the page control, not the user dragging
return;
}
// Switch the indicator when more than 50% of the previous/next page is visible
CGFloat pageWidth = scrollView.frame.size.width;
int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
pageControl.currentPage = page;
// load the visible page and the page on either side of it (to avoid flashes when the user starts scrolling)
[self loadScrollViewWithPage:page - 1];
[self loadScrollViewWithPage:page];
[self loadScrollViewWithPage:page + 1];
// A possible optimization would be to unload the views+controllers which are no longer visible
}
// At the begin of scroll dragging, reset the boolean used when scrolls originate from the UIPageControl
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
pageControlUsed = NO;
}
- (IBAction)changePage:(id)sender {
int page = pageControl.currentPage;
// load the visible page and the page on either side of it (to avoid flashes when the user starts scrolling)
[self loadScrollViewWithPage:page - 1];
[self loadScrollViewWithPage:page];
[self loadScrollViewWithPage:page + 1];
// update the scroll view to the appropriate page
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
[scrollView scrollRectToVisible:frame animated:YES];
// Set the boolean used when scrolls originate from the UIPageControl. See scrollViewDidScroll: above.
pageControlUsed = YES;
}
#end
MyViewController.h
#import <UIKit/UIKit.h>
#interface MyViewController : UIViewController {
UILabel *pageNumberLabel;
int pageNumber;
}
#property (nonatomic, retain) IBOutlet UILabel *pageNumberLabel;
- (id)initWithPageNumber:(int)page initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
#end
MyViewController.m
#import "MyViewController.h"
#implementation MyViewController
#synthesize pageNumberLabel;
- (void)loadView {
}
- (void)viewDidLoad {
[super viewDidLoad];
// Set the label and background color when the view has finished loading
pageNumberLabel.text = [NSString stringWithFormat:#"Page %d", pageNumber + 1];
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
// Load the view nib and initialize the pageNumber ivar
// classic initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
// class adapted to init the page number
// /!\ be careful, I'm not sure it's working properly
- (id)initWithPageNumber:(int)page initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
pageNumber = page;
NSLog(#"pageNumber = %i", pageNumber);
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#end
The unrecognized selector error is happening because you are redeclaring your local variable "controller" within the if statement in loadScrollViewWithPage: Because you are doing so, the new controller variable only exists within the scope of the if statement, and when you exit the if statement the controller variable outside that scope is still NSNull.
You can fix by removing the variable definition inside the if statement:
if ((NSNull *)controller == [NSNull null])
{
controller = [self.storyboard instantiateViewControllerWithIdentifier:#"MVC"];
[controller initWithPageNumber:page];
[viewControllers replaceObjectAtIndex:page withObject:controller];
}
So I've been having exactly the same problem you were having but I just did something that might have worked just fine.
Short answer is an addition to Jonkroll's answer about initiating the controller inside the if statement. For some reason I can't explain the empty placeholder is not null so the if statement doesn't execute as you pointed out in your code. So what I did was modify the if and add an else to that same if and load the ViewController from the storyboard.
if ((NSNull *)controller == [NSNull null]) {
controller = [self.storyboard instantiateViewControllerWithIdentifier:#"MVC"];
[viewControllers replaceObjectAtIndex:page withObject:[controller initWithPageNumber:page]];
}
else {
controller = [self.storyboard instantiateViewControllerWithIdentifier:#"MVC"];
[viewControllers replaceObjectAtIndex:page withObject:[controller initWithPageNumber:page]];
}
The rest of my code is exactly as yours. I know is not the best code ever and I might be ok by just initiating the ViewController without an if/else statement all together but I don't have the answer as to why this is needed or worst why is not actually working as I expect. If anyone knows please share.
First of all, thanx for this thread, it indeed served as a kind of a tutorial or a reference to me.
I did everything almost exactly like you did, except in content controller i put following code (based on #jonkroll's answer):
if ((NSNull *)controller == [NSNull null]){
controller = [[self.storyboard instantiateViewControllerWithIdentifier:#"MyViewController"] initWithPageNumber:page initWithNibName:nil bundle:nil];
[viewControllers replaceObjectAtIndex:page withObject:controller];
}
MyViewController (has different name in my case, but it's of no relevance) inherits from UITableViewController, because it was kind of stuff i needed.
My initWithPageNumber method looks like this:
- (id)initWithPageNumber:(int)page initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
pageNumber = page;
NSLog(#"PageNumber = %i", pageNumber);
return self;
}
Added return.self, notice that.
One, last thing is, i embedded ContentController in Navigation controller, via editor->embed in->navigation controller.
That's pretty much everything. Later, i even managed to get navigation from MyViewController to another view and everything works fine.
If you need further help, you are free to ask here.
Regards.
I had the same problem with you when I tried to follow the sample code of UIPageController from Apple Documents. For I did my MyViewController programmatically, so I directly use the following code
if ((NSNull *)controller == [NSNull null])
{
MyViewController * controller = [[MyViewController alloc]init];
[viewControllers replaceObjectAtIndex:page withObject:controller];
}
And I changed nothing in MyViewController.