开发者

How To remove an Item from TTLauncher / Three20?

how to remove a Item after add this in the Pages-Array?

I tried it here:

 launcherView.pages = [NSArray arrayWithObjects:
                      [NSArray arrayWithObjects:
                       [self launcherItemWithTitle:@"Pers. Starts."
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://startseit开发者_JAVA百科e"],
                       [self launcherItemWithTitle:@"ENS"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://ens"],
                       [self launcherItemWithTitle:@"Kontakte"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://kontakte"],
                       [self launcherItemWithTitle:@"Einstellungen"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://einstellungen"],
                       [self launcherItemWithTitle:@"Admin"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://admin"]
                       , nil]
                      , nil];


//Check if ENS-Admin enabled
if ([SelfViewHandler IsENSAdminSet])
{
    TTLauncherItem* item;
    item = [launcherView itemWithURL:@"tt://admin"];

    [launcherView removeItem:item animated:false];
}

But the Item is still there. (If-Clause is true, checked it in Debugger and Breakpoint)


The object item = [launcherView itemWithURL:@"tt://admin"] is actually doesn't exists in your TTLauncherView and isn't being removed because of that.

Each object gets a reference when it's being created so the object you're adding when creating the pages array and the object you're creating in your if statement are different.

In order to remove an object from TTLauncherView, you need a reference to it. You can do something like that:

TTLauncherItem* item = [self launcherItemWithTitle:@"Admin"
                                         image:@"bundle://animexx-72.png"
                                           URL:@"tt://admin"]

launcherView.pages = [NSArray arrayWithObjects:
                      [NSArray arrayWithObjects:
                       [self launcherItemWithTitle:@"Pers. Starts."
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://startseite"],
                       [self launcherItemWithTitle:@"ENS"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://ens"],
                       [self launcherItemWithTitle:@"Kontakte"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://kontakte"],
                       [self launcherItemWithTitle:@"Einstellungen"
                                             image:@"bundle://animexx-72.png"
                                               URL:@"tt://einstellungen"],
                       adminLauncherItem
                       , nil]
                      , nil];


//Check if ENS-Admin enabled
if ([SelfViewHandler IsENSAdminSet])
{
    [launcherView removeItem:adminLauncherItem animated:false];
}

It makes sense to have a function that removes a launcher item based on the URL, like

- (void)removeItemWithURL:(NSURL*)url animated:(BOOL)animated {

(but there isn't yet :-) )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜