# Share single view problem

**URL:** <https://devforum.zoom.us/t/share-single-view-problem/59726>\
**Category:** iOS\
**Created:** [November 3, 2021, 8:04am UTC](https://devforum.zoom.us/t/share-single-view-problem/59726 "2021-11-03T08:04:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [November 3, 2021, 8:04am UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/1 "2021-11-03T08:04:03Z")

</div>

Continuing the discussion from [Can't use the appShareWithView](https://devforum.zoom.us/t/cant-use-the-appsharewithview/56311/25):

Since the post had been locked. I create a new one.

I double-check the SDK reference ([https://marketplace.zoom.us/docs/sdk/native-sdks/iOS/mastering-zoom-sdk/in-meeting-function/screen-share](https://marketplace.zoom.us/docs/sdk/native-sdks/iOS/mastering-zoom-sdk/in-meeting-function/screen-share))

I found that there are to type of sharing.

1. Screen Broadcast with ReplayKit.
2. share Single UIView

What I want to do should be the second one. As a result, I didn’t add the screenShare framework to my Xcode project. Is it the reason why I called the method but have nothing happened?

And I found that if need to use the appShareWithView, it needs the enable the Custom Meeting UI, is that need if we are using [ms meetingView], this function will not be able to use?

For your information, actually, I want to do the function is like the Zoom app, just share a picture with the participants.

> ![IMG_8978.PNG](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/e/9/e9e1e33c24aeec43ec42a099b180cf67c617d8e1.jpeg) photos

and

> ![IMG_8979.PNG](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/4/b/4bf39cd38f43d6cc9399ffd02b19beb0956f2a51.jpeg) share the photo

Thank you so much.

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [November 4, 2021, 10:42pm UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/2 "2021-11-04T22:42:13Z")

</div>

Hey @lemon97213,

Thanks for using the dev forum!

Yes you can use this in default UI actually. Try this code before calling appShareWithView:  
MobileRTCMeetingService \*ms = [[MobileRTC sharedRTC] getMeetingService];  
if (ms) {  
if (ms.isStartingShare) {  
[ms stopAppShare];  
} else {  
[ms startAppShare];  
}  
}

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [November 5, 2021, 2:10am UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/3 "2021-11-05T02:10:47Z")

</div>

So I don’t need the “Replaykit” ?

---

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [November 5, 2021, 9:43am UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/4 "2021-11-05T09:43:17Z")

</div>

> ![Screenshot 2021-11-05 at 5.29.46 PM](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/1/3/13a293564d543b5effff251aa244b07ab979a45e.jpeg)  
> Here is my code  
> You can see the line in blue highlight. I found that it print out “Sharing Started” every time I clicked the button to call this function. So it should never trigger the “[ms startAppShare]” function. And the image didn’t show.

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [November 9, 2021, 6:11pm UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/5 "2021-11-09T18:11:51Z")

</div>

Hey @lemon97213,

Does this happen with other UIViews besides the meetingView?

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![lemon97213](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lemon97213/32/30378_2.png) [@lemon97213](https://devforum.zoom.us/u/lemon97213)\
**Post date:** [November 10, 2021, 3:31am UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/6 "2021-11-10T03:31:12Z")

</div>

@Michael_Condon  
Sorry, I am not very understanding. i tried to add this in different function, it is still don’t work. And The app now only have one view which is the meetingview while the meeting started.

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [November 11, 2021, 11:49pm UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/7 "2021-11-11T23:49:00Z")

</div>

Hey @lemon97213,

Can you try this code:

```auto
//
// ViewController.m
// AppShareWithViewExample
//
// Created by Michael Condon on 9/22/21.
//

#import "ViewController.h"

@interface ViewController ()

@property (nonatomic) UIView* localView;
@property (nonatomic) UIView* remoteView;
@property (nonatomic) UIView* shareView;
@property (nonatomic) UILabel* waitingRoomLabel;
@property (nonatomic) UIButton* joinMeetingButton;
@property (nonatomic) UIButton* startAppShareButton;

@end

@implementation ViewController

NSString* appGroupId = @"";
NSString* JWT = @"";
NSString* meetingNumber = @"";
NSString* meetingPassword = @"";

- (void)loadView {
    [super loadView];
    
    [self initializeSDK];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupViews];
}

- (void)initializeSDK {
    MobileRTCSDKInitContext *initContext = [[MobileRTCSDKInitContext alloc] init];
    initContext.appGroupId = appGroupId;
    initContext.domain = @"https://zoom.us";
    
    if ([[MobileRTC sharedRTC] initialize:initContext] == YES) {
        MobileRTCAuthService* authService = [[MobileRTC sharedRTC] getAuthService];
        if (!authService) {
            return;
        }
        
        authService.jwtToken = JWT;
        authService.delegate = self;
        
        [authService sdkAuth];
    }
}

- (void)setupViews {
    CGFloat screenCenterX = self.view.center.x - 50;
    
    UIView *localView = [[UIView alloc] initWithFrame:CGRectMake(screenCenterX, 0, 100, 100)];
    localView.backgroundColor = [UIColor redColor];
    [[self view] addSubview:localView];
    self.localView = localView;
    
    UIView *remoteView = [[UIView alloc] initWithFrame:CGRectMake(screenCenterX, 100, 100, 100)];
    remoteView.backgroundColor = [UIColor blueColor];
    [[self view] addSubview:remoteView];
    self.remoteView = remoteView;
    
    UIView *shareView = [[UIView alloc] initWithFrame:CGRectMake(screenCenterX, 200, 100, 100)];
    shareView.backgroundColor = [UIColor greenColor];
    [[self view] addSubview:shareView];
    self.shareView = shareView;
    
    UIButton *joinMeetingButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [joinMeetingButton addTarget:self
               action:@selector(joinMeeting:)
     forControlEvents:UIControlEventTouchUpInside];
    [joinMeetingButton setTitle:@"Join Meeting" forState:UIControlStateNormal];
    joinMeetingButton.frame = CGRectMake(screenCenterX, 300, 100, 50);
    [[self view] addSubview:joinMeetingButton];
    self.joinMeetingButton = joinMeetingButton;
    
    UILabel *waitingRoomLabel = [[UILabel alloc] initWithFrame:CGRectMake(screenCenterX, 350, 300, 100)];
    waitingRoomLabel.text = @"Not yet in meeting.";
    [[self view] addSubview:waitingRoomLabel];
    self.waitingRoomLabel = waitingRoomLabel;
    
    UIButton *startAppShareButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [startAppShareButton addTarget:self
                          action:@selector(startAppShare:)
     forControlEvents:UIControlEventTouchUpInside];
    [startAppShareButton setTitle:@"Start app share" forState:UIControlStateNormal];
    startAppShareButton.frame = CGRectMake(screenCenterX, 400, 100, 50);
    [[self view] addSubview:startAppShareButton];
    self.startAppShareButton = startAppShareButton;
}

- (void)joinMeeting:(UIButton*)sender {
    MobileRTCMeetingService *meetService = [[MobileRTC sharedRTC] getMeetingService];
    MobileRTCMeetingSettings *meetSettings = [[MobileRTC sharedRTC] getMeetingSettings];

    if (!meetService) {
        return;
    }
    if (!meetSettings) {
        return;
    }
    
    meetService.delegate = self;
    meetService.customizedUImeetingDelegate = self;
    
    MobileRTCMeetingJoinParam *joinParams = [[MobileRTCMeetingJoinParam alloc] init];
    joinParams.meetingNumber = meetingNumber;
    joinParams.password = meetingPassword;
    joinParams.userName = @"ios sdk";
    
    meetSettings.enableCustomMeeting = YES;
    
    MobileRTCMeetError joinMeetingReturnValue = [meetService joinMeetingWithJoinParam:joinParams];
    if (joinMeetingReturnValue == MobileRTCMeetError_Success) {
        NSLog(@"Joining meeting");
    } else {
        NSLog(@"Failed to join meeting");
    }
}

- (void)showAttendeeVideos {
    MobileRTCVideoView *localVideoView = [[MobileRTCVideoView alloc] initWithFrame:self.localView.bounds];
    [localVideoView setVideoAspect:MobileRTCVideoAspect_PanAndScan];
    [self.localView addSubview:localVideoView];
    NSUInteger myUserID = [[[MobileRTC sharedRTC] getMeetingService] myselfUserID];
    [localVideoView showAttendeeVideoWithUserID:myUserID];
    
    NSArray *inMeetingParticipants = [[[MobileRTC sharedRTC] getMeetingService] getInMeetingUserList];
    NSUInteger otherUserID = 0;
    for (NSNumber *currentUserID in inMeetingParticipants) {
        if ([currentUserID unsignedIntegerValue] != myUserID) {
            otherUserID = [currentUserID unsignedIntegerValue];
            break;
        }
    }
    
    if (otherUserID == 0) {
        return;
    }
        
    MobileRTCVideoView *remoteVideoView = [[MobileRTCVideoView alloc] initWithFrame:self.remoteView.bounds];
    [remoteVideoView setVideoAspect:MobileRTCVideoAspect_PanAndScan];
    [self.remoteView addSubview:remoteVideoView];
    [remoteVideoView showAttendeeVideoWithUserID:otherUserID];
}

- (void)startAppShare:(UIButton*)sender {
    MobileRTCMeetingService *meetService = [[MobileRTC sharedRTC] getMeetingService];

    if (!meetService) {
        return;
    }
    
    if (meetService.isStartingShare) {
        [meetService stopAppShare];
    } else {
        [meetService startAppShare];
        ViewController* __weak weakSelf = self;
        dispatch_async(dispatch_get_main_queue(), ^{
            ViewController* strongSelf = weakSelf;
            if (strongSelf) {
                [meetService appShareWithView:strongSelf.shareView];
            }
        });
    }
}

// #pragma mark - MobileRTCAuthDelegate

- (void)onMobileRTCAuthReturn:(MobileRTCAuthError)returnValue {
    switch (returnValue) {
        case MobileRTCAuthError_Success:
            NSLog(@"SDK Authed");
            break;
            
        default:
            NSLog(@"Could not auth SDK.");
            break;
    }
}

// #pragma mark - MobileRTCMeetingServiceDelegate

- (void)onMeetingError:(MobileRTCMeetError)error message:(NSString *)message {
    switch (error) {
        case MobileRTCMeetError_Success:
            break;
            
        default:
            NSLog(@"MobileMeetError: %lu", (unsigned long)error);
    }
}

- (void)onWaitingRoomStatusChange:(BOOL)needWaiting {
    if (needWaiting == YES) {
        NSLog(@"In waiting room...");
        if (!_waitingRoomLabel) {
            return;
        }
        
        _waitingRoomLabel.text = @"in waiting room";
    } else {
        NSLog(@"Left waiting room.");
        if (!_waitingRoomLabel) {
            return;
        }
        
        _waitingRoomLabel.text = @"Left waiting room";
        
        [self showAttendeeVideos];
    }
}

- (void)onJoinMeetingConfirmed {
    NSLog(@"Joined meeting.");
}

- (void)onJoinMeetingInfo:(MobileRTCJoinMeetingInfo)info completion:(void (^)(NSString * _Nonnull, NSString * _Nonnull, BOOL))completion {
    NSLog(@"Invalid meeting credentials");
}

- (void)onJBHWaitingWithCmd:(JBHCmd)cmd {
    switch (cmd) {
        case JBHCmd_Show:
            NSLog(@"Joined before host.");
            break;
            
        default:
            break;
    }
}

- (void)onDestroyMeetingView {
    return;
}

- (void)onInitMeetingView {
    return;
}

@end

```

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 12, 2021, 9:49am UTC](https://devforum.zoom.us/t/share-single-view-problem/59726/8 "2021-12-12T09:49:49Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
