我有一个tableViewHeader UIView,它包含一些动态元素(准确地说具有不同大小的UILabel).我将UIView设置为IB,将所有内容连接起来,并尝试在sizeToFit之后根据标签的大小更改帧起源.
如果我在setFrame调用后记录新帧,它实际上会显示更新的原点,但它们不会显示在模拟器上.标签会改变高度,但起源不会改变.
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect frame;
CGFloat baseOffset = titleLbl.frame.origin.y;
offset = titleLbl.frame.size.height;
self.titleLbl.text = destObject.title;
self.titleLbl.font = [UIFont fontWithName:@"Avenir-Heavy" size:22];
[self.titleLbl sizeToFit];
frame = titleLbl.frame;
frame.origin.y = baseOffset;
//Get any change in size from the label
offset = titleLbl.frame.size.height - offset;
frame = imageView.frame;
frame.origin.y = frame.origin.y + offset;
self.imageView.frame = frame;
frame = photosBtn.frame;
frame.origin.y = frame.origin.y + offset;
[self.photosBtn setFrame:frame];
frame = detailLbl.frame;
frame.origin.y = frame.origin.y + offset;
self.detailLbl.frame = frame;
baseOffset = …Run Code Online (Sandbox Code Playgroud) 我一直在努力寻找一些似乎应该"正常工作"一段时间的事情.我通过Urban Airship建立了推送通知,除了应用程序在后台的徽章更新外,一切正常.据我所知,只要将徽章设置为有效负载中的整数,如果应用程序不在前台,这应该自行处理.
如果我在应用程序位于前台时捕获徽章更新,我可以正确设置它,但这不是我想在我的应用程序中使用徽章的原因.
这是我的设置 didFinishLaunchingWithOptions:
UAConfig *config = [UAConfig defaultConfig];
// You can also programatically override the plist values:
// config.developmentAppKey = @"YourKey";
// etc.
// Call takeOff (which creates the UAirship singleton)
[UAirship takeOff:config];
[UAPush shared].notificationTypes = (UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeNewsstandContentAvailability);
[[UAPush shared] setPushEnabled:YES];
[[UAPush shared] setAutobadgeEnabled:YES];
[self performSelector:@selector(resetUABadge:)];
[[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
applicationState:application.applicationState];
Run Code Online (Sandbox Code Playgroud)
当应用程序启动时,resetUABadge调用只会将所有内容设置回0.无论performSelector是否存在,此问题都会持续存在.
我不确定是否有一些我缺少的配置或者什么,但推送通知的其他部分在应用程序背景/关闭(警报,声音)时有效,但徽章根本不会更新.