收到推送通知时,从视图中选择一行 [英] select a row from view when a push notification is received

查看:85
本文介绍了收到推送通知时,从视图中选择一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在收到推送通知时从表格视图中选择一行。

I am trying to select a row from a table view when a push notification is received.

我有myprojectAppDelegate.h

I have myprojectAppDelegate.h

#import <UIKit/UIKit.h>
#import "iw.h"
#import "Bookmark.h"


@interface myprojectAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
    UIWindow               *window;
    UITabBarController     *tabBarController;
    UINavigationController *navigationController;
    NSMutableArray                  *tableData;
    NSMutableArray                  *imagesList;
    IBOutlet Bookmark               *tableCell;
}

@property (nonatomic, retain) IBOutlet UIWindow               *window;
@property (nonatomic, retain) IBOutlet UITabBarController     *tabBarController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property(nonatomic, retain) NSMutableArray                  *tableData;
@property(nonatomic, retain) NSMutableArray                  *imagesList;

- (BOOL)getIsLaunched;
- (void)showService;
- (void)showMessage;
- (void) loadLogoList;
+ (const NSString*)getVersion;
+ (const NSString*)getXMLversionURL;
+ (NSMutableDictionary *)logos;
+ (void)setLogos:(NSMutableDictionary *)newDictionary;
- (void)checkVersion;

@end

并在myprojectAppDelegate.m文件中实现didReceiveRemoteNotification
但是tableview是在另一个类bookmarklist.m中实现的,当应用程序在启动选项后启动它导航到bookmarklist.m并显示表视图。

and implementing the didReceiveRemoteNotification in myprojectAppDelegate.m file But the tableview is implemented in another class bookmarklist.m when the app start after launch options it navigates to bookmarklist.m and displays the table view.

我想要访问bookmarklist.m中的tableview,并在收到推送通知时选择表格中的一行。

I want to access that tableview which is in bookmarklist.m and select a row in the table when ever i receive a push notification.

请帮助我。我是ios编程的新手。

please help me with this. i am new to ios programming.

谢谢。

推荐答案

你可以在 bookmarklist.m 类中添加一个观察者方法,如下所示

You can add an observer method in your bookmarklist.m class like this

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(newMessageReceived:) name:@"NEWMESSAGE" object:nil];

并在同一个班级中添加此观察者方法

and add this observer method in the same class

-(void)newMessageReceived:(NSNotification *) notification{
       //Here you can select the row you want to be selected
}

然后在 appDelegate中的 didReceiveRemoteNotification 文件,发布这样的通知并传递您想要在对象参数中发布的数据。

Then in your didReceiveRemoteNotification in appDelegate file, post a notification like this and pass the data you want to post in object parameter.

[[NSNotificationCenter defaultCenter] postNotificationName:@"NEWMESSAGE" object:nil]; 

希望这会有所帮助。

这篇关于收到推送通知时,从视图中选择一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆