質問

I want show a APNS device token with UILabel.

So I coded below:

//AppDelegate.m

- (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
// TODO: Pass the token to our server
NSString *devToken = [[[[deviceToken description] 
                        stringByReplacingOccurrencesOfString:@"<"withString:@""] 
                       stringByReplacingOccurrencesOfString:@">" withString:@""] 
                      stringByReplacingOccurrencesOfString: @" " withString: @""];


NSString *str = [NSString 
                 stringWithFormat:@"Device Token=%@",devToken];
UIAlertView *alertCtr = [[UIAlertView alloc] initWithTitle:@"Token is " message:devToken delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: nil];
[alertCtr show];
NSLog(@"device token - %@",str);
viewc = [ViewController alloc];

viewc.tokenLabel.text = str;

}

But nothing happend. What's wrong?

役に立ちましたか?

解決

viewc = [ViewController alloc];
viewc.tokenLabel.text = str;

After alloc'ing your view controller, you should init it too. And present it, whether modally or in a navigation controller or something else, it's up to you.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top