UIBarButton 忽略“setEnabled:YES”
我遇到了问题。我无法想象为什么会发生这种情况,也许你们可以。
我在 IB 中创建了一个 UIBarButtonItem 并正确链接它。 A设置属性并合成它。一开始我将 btn 设置为禁用(viewWillAppear)。 然后我尝试向我的 mysql 数据库添加一个条目:
NSString *URLStr = [NSString stringWithFormat:@"http://www.justfortestingandsoon.com/example.php?entry=%@", myEntry];
URLStr = [URLStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSLog(@"URLStr: %@",URLStr);
NSURL *addURL = [NSURL URLWithString:URLStr];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:addURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
urlConnectionSet = [NSURLConnection connectionWithRequest:urlRequest delegate:self];
在它的“didReceiveData...”中,我检查返回哪个值:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSData *myData;
myData = data;
NSString *testString = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding];
NSLog(@"receivedData: %@", testString);
if ([testString isEqualToString:@"ENABLED"]) {
self.notificationBtnDeactivate.enabled = YES;
}
...
我已经调试了它。该行 self.notificationBtnDeactivate.enabled = YES;被调用但 UI 上没有任何明显的变化。
有什么想法吗?
多谢!
I ran into a problem. I can't image why that happens, probably you guys can.
I've created a UIBarButtonItem in IB and linked it correctly. A set the property and synthesized it. At the beginning I set the btn disabled (viewWillAppear).
Then I try to add an entry to my mysql db:
NSString *URLStr = [NSString stringWithFormat:@"http://www.justfortestingandsoon.com/example.php?entry=%@", myEntry];
URLStr = [URLStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSLog(@"URLStr: %@",URLStr);
NSURL *addURL = [NSURL URLWithString:URLStr];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:addURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0];
urlConnectionSet = [NSURLConnection connectionWithRequest:urlRequest delegate:self];
In it's "didReceiveData..." I check which value gets returned:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSData *myData;
myData = data;
NSString *testString = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding];
NSLog(@"receivedData: %@", testString);
if ([testString isEqualToString:@"ENABLED"]) {
self.notificationBtnDeactivate.enabled = YES;
}
...
I already debugged it. The line self.notificationBtnDeactivate.enabled = YES; gets called but without any noticable changes on the UI.
Any Ideas?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此有两个想法:
I have two ideas for this: