0
votes

I have a view in Which I have added a UIScrollview. In UIScrollView I added an UIImageView. After Picking Image from ImagePicker I am adding image to UIImageView.

Problem : I am showing UIActivityIndicatorView before adding image to ImageView.

Case 1: When I add activity Indicator to self.view It is showing behind the UIScrollView means not showing at all.

Case 2: If I add Indicator to Scrollview it is not adding in view.

I tried many thing bringSubviewToFront , insertSubview:indicator aboveSubview:myscrollview

Here is my CODE :

  scroller = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 60, Screen_width, Screen_height - 60)];
scroller.delegate = self;
[self.view addSubview:scroller];
scroller.contentSize = CGSizeMake(Screen_width, 667);


profileImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, Screen_width-40, Screen_width-40)];
profileImageView.backgroundColor = gray;
profileImageView.contentMode = UIViewContentModeScaleAspectFill;
profileImageView.clipsToBounds = YES;
profileImageView.userInteractionEnabled=YES;


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{

_profileIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_profileIndicator.frame = CGRectMake(40.0, 20.0, 60.0, 60.0);
_profileIndicator.center = self.view.center;
[self.view addSubview:_profileIndicator];
[_profileIndicator startAnimating];




}
1
Have you tried showing it on main thread? Try viewDebugging to get the root cause.Bharat Modi
you are adding UIActivityIndicatorView into your view but your code in picker delegate check your picker delegate.so this will present a new view controller.It wont show your indicatorkarthikeyan
Indicator is adding on View but below scrollview.M Swapnil

1 Answers

0
votes

All the UI things should be in main thread. So, please make sure you are using UIActivityIndicator in main thread.