मुझे दृश्य से एक बटन निकालने और एक अलग जोड़ने में सक्षम होना चाहिए। मेरा कोड इस तरह दिखता है:removeFromSuperview काम नहीं करता
-(void)UpdatePromoBanner:(NSString*)value{
[button setTitle:@"newer text" forState:UIControlStateNormal];
for (UIView *subView in emptyViewController.view.subviews)
{
if(subView.tag == 99) {
//--remove button and add an updated one
NSLog(@"Remove button?");
[subView removeFromSuperview];
//[subView.superview addSubview:button];
}
}
NSLog(@"event called");
}
-(void)AddPromoBannerToBottom:(UIView*)view {
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:lblForBannerButton forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
button.tag = 99;
[view addSubview:button];
}
खाली दृश्य नियंत्रक केवल एक सादा खाली दृश्य नियंत्रक है। मैं बीच में एक बटन जोड़ रहा हूँ। मैंने NSLog को ठीक किया है जो टैग की जांच करता है, लेकिन दृश्य हटाया नहीं जाता है। मुझे जिक्र करना चाहिए कि मैं एक थ्रेड का उपयोग कर रहा हूं जो हर 5 सेकंड में अपडेटप्रोमोनेर को फायर कर रहा है।
छोटे अक्षरों के साथ अपने विधि के नाम से शुरू करें। –