[IOS development] Customize the navigation bar of the Rongyun selection location page and location information page

[IOS development] Customize the navigation bar of the Rongyun selection location page and location information page

  1. Select location page
    • Create a subclass of RCLocationPickerViewController: RCDLocationViewController, you can customize the left and right buttons of the navigation bar
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"自定义左按钮" style:UIBarButtonItemStyleDone target:self action:@selector(leftItemDidPressed:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor redColor];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"自定义右按钮" style:UIBarButtonItemStyleDone target:self action:@selector(rightItemDidPressed:)];
    self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
}
- (void)leftItemDidPressed:(id)sendr {
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)rightItemDidPressed:(id)sendr {
    [super rightBarButtonItemPressed:nil];
}
  • Override the following methods in the chat page subclass, and set the proxy to present to the object of the subclass.

/*!
 扩展功能板的点击回调

 @param pluginBoardView 输入扩展功能板View
 @param tag             输入扩展功能(Item)的唯一标示
 */
- (void)pluginBoardView:(RCPluginBoardView *)pluginBoardView clickedItemWithTag:(NSInteger)tag {
    switch (tag) {
           case PLUGIN_BOARD_ITEM_LOCATION_TAG: {
               RCDLocationViewController *vc = [[RCDLocationViewController alloc] init];
               vc.delegate = self;
               UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:vc];
               [self presentViewController:navi animated:YES completion:nil];
           }
               break;

           default:
               [super pluginBoardView:pluginBoardView clickedItemWithTag:tag];
               break;
       }
}
  • The chat page subclass needs to follow the proxy RCLocationPickerViewControllerDelegate and implement the method:

    
    /*!
    地理位置选择完成之后的回调
    
    @param locationPicker 地理位置选取的ViewController
    @param location       位置的二维坐标
    @param locationName   位置的名称
    @param mapScreenShot  位置在地图中的缩略图
    
    @discussion
    如果您需要重写地理位置选择的界面,当选择地理位置完成后,需要调用此回调通知RCConversationViewController定位已完成,可以进一步生成位置消息并发送。
    */
  • (void)locationPicker:(RCLocationPickerViewController )locationPicker
    didSelectLocation:(CLLocationCoordinate2D)location
    locationName:(NSString
    )locationName
    mapScreenShot:(UIImage )mapScreenShot {
    RCLocationMessage
    locationMessage =
    [RCLocationMessage messageWithLocationImage:mapScreenShot location:location locationName:locationName];
    [self sendMessage:locationMessage pushContent:nil];
    }
2. 位置信息页面
- 创建 RCLocationViewController 的子类LocationViewController

```objective-c
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"自定义左按钮" style:UIBarButtonItemStyleDone target:self action:@selector(leftItemDidPressed:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor redColor];

    self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
}
- (void)leftItemDidPressed:(id)sendr {
    [self dismissViewControllerAnimated:YES completion:nil];
}
  • Override the callback of the click location message on the conversation page

/**

  • Open geographic location. Developers can rewrite and open the map to display the location based on the latitude and longitude. Use built-in map by default
  • @param locationMessageContent location message
    */
    • (void)presentLocationViewController:(RCLocationMessage )locationMessageContent {
      // LocationViewController为 RCLocationViewController 的子类
      LocationViewController
      locationViewController = [[LocationViewController alloc] init];
      locationViewController.locationName = locationMessageContent.locationName;
      locationViewController.location = locationMessageContent.location;
      locationViewController.modalPresentationStyle = UIModalPresentationFullScreen;
      UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:locationViewController];
      navc.modalPresentationStyle = UIModalPresentationFullScreen;
      [self presentViewController:navc animated:YES completion:NULL];
      }

Guess you like

Origin blog.51cto.com/15056506/2678331