add clear chat history button on homepage in wechat

1.Tweak.xm

%new
- (void)clickLeftItem:(UIButton *)button {
  [UIAlertView showWithTitle:@"clear"
                       message:@"are you sure to clear chat list?"
             cancelButtonTitle:@"OK"
             otherButtonTitles:@[@"CANCEL"]
                      tapBlock:^(UIAlertView *alertView, NSInteger buttonIndex) {
      if (buttonIndex == [alertView cancelButtonIndex]) {
          NSLog(@"ok");
          UIViewController *viewController = [objc_getClass("SettingGeneralViewController") new];
          objc_msgSend(viewController,NSSelectorFromString(@"clearLocalData"));
      } else if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"CANCEL"]) {
          NSLog(@"cancel");
      }
  }];
}

%end

if want to know how to add left bar button ,please check the before blog.

2.effect

add clear chat history button on homepage in wechat_第1张图片
clear chat history

after click ok button, the chat history will be cleared.

3. Postscript

any problem can comment below, I will response you.

你可能感兴趣的:(add clear chat history button on homepage in wechat)