开发者

REALLY simple question about UIViews

开发者 https://www.devze.com 2022-12-16 01:32 出处:网络
I am working on an app that has several different views, two of the which are DetailViewController.h&.m and AddViewController.h&.m. Neither of these particular view have IB xib files associate

I am working on an app that has several different views, two of the which are DetailViewController.h&.m and AddViewController.h&.m. Neither of these particular view have IB xib files associated with them, they just have programmatically generated UITableViews. These views essentially are the same, the only difference, i开发者_运维技巧s that in the AddViewController, you put info into cells, and in the DetailViewController that same info is viewable and editable. Essentially the viewDidLoad for the AddViewController overrides the DetailViewController viewDidLoad with different navigation bar items and title. MY QUESTION: Outside of IB, how do I reference which view I am in? I want to have some switches and buttons available in the DetailView, that I don't want available in the AddView. But being that as it is, they are refferencing the same info, and currently just changing the navigation bar items, they aren't seperate like I would like them to be. Inside the DetailView viewDidLoad I'm thinking I need something where its like

if(currentView = DetailView) {
self.view addSubview: onOffSwitch;
}
else onOffSwitch. hidden = YES;

Or something to that effect. Obviously if the above code actually worked, I wouldn't be writing this question :) Its probably just a syntax issue I can't hammer out, if you could please help me out, it would be greatly appreciated! Thanks


Well there is similar question here

But for your case you can do it like:

if([[self class] isKindOfClass:[DetailViewController class]]) {
self.view addSubview: onOffSwitch;
}
else 
onOffSwitch. hidden = YES;
0

精彩评论

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