开发者

UITableView Trouble

My navigation Controller 's Root viewController is UIViewController(rootViewController). It contain's a UITableView, as follows: alt text http://www.freeimagehosting.net/uploads/c9b0985b63.png

When i press the arrow button(call the function in rootViewController), the tableview will move t开发者_如何学编程o left until only the arrow button left on the left edge.

But now i also want to press the cell to make the same function. But the problem is the method didSelectRowAtIndexPath: cant call that function in rootViewController. So how should make this ?

I guess use addObserver method, but know nothing about this , anyone can explain or give me some idea , thanks a lot!


Two ways: 1.Make the "Map" view controller is the delegate of navigation view controller. Then in

didSelectRowAtIndexPath:

call the [delegate buttonPressed]; 2. When the button was pressed first time, add a observer:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(buttonPressed:) name:@"flip_the_navigation_controller" object:nil];

Then when the cell was pressed, post a notificatoin:

[[NSNotificationCenter defaultCenter] postNotificationName:@"flip_the_navigation_controller" object:nil];

And remove the observer in dealloc method:

[[NSNotificationCenter defaultCenter] removeObserver:self];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜