iPhone - 5.1(9B176)
I have been encountering inconsistent behaviour in overlaying a mask view on top of a UITableViewController as shown in picture below. Anyone encountered this behaviour, if yes, please suggest any solutions used?
Below is the code i have used to add mask view:
//Add the overlay view.
if(ovController == nil) {
NSString *cellIdentifier = #"overlayVC";
ovController = [[self storyboard] instantiateViewControllerWithIdentifier:cellIdentifier];
}
CGFloat yaxis = self.navigationController.navigationBar.frame.size.height;
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
CGRect frame = CGRectMake(0, yaxis, width, height);
ovController.view.frame = frame;
ovController.view.alpha = 0.85;
ovController.delegate = self;
UIView *aboveView = self.parentViewController.view;
[self.tableView insertSubview:ovController.view aboveSubview:aboveView];
I have also tried
`[self.tableView insertSubview:ovController.view aboveSubview:self.tableView]`
Hi use something like below code
-(void) showLoadingView {
//NSLog(#">>>>>>>>>>>>>>>>> loading view Landscape right ");
if (loadView == nil) {
loadView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
loadView.opaque = NO;
loadView.backgroundColor = [UIColor clearColor];
//loadView.alpha = 0.8;
viewBack = [[UIView alloc] initWithFrame:CGRectMake(95, 230, 130, 40)];
viewBack.backgroundColor = [UIColor blackColor];
viewBack.alpha = 0.7f;
viewBack.layer.masksToBounds = NO;
viewBack.layer.cornerRadius = 8;
spinningWheel = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(5.0, 5.0, 30.0, 30.0)];
[spinningWheel startAnimating];
// spinningWheel.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[viewBack addSubview:spinningWheel];
[spinningWheel release];
UILabel *lblLoading = [[UILabel alloc] initWithFrame:CGRectMake(23, 6, 110, 25)];
lblLoading.backgroundColor = [UIColor clearColor];
lblLoading.font = [UIFont fontWithName:#"Helvetica-Bold" size:16.0];
lblLoading.textAlignment = UITextAlignmentCenter;
lblLoading.textColor = [UIColor whiteColor];
lblLoading.text = #"Loading...";
[viewBack addSubview:lblLoading];
[loadView addSubview:viewBack];
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
loadView.frame = iphoneFrame;
viewBack.frame = loadiPhone;
}
else
{
loadView.frame = ipadFrame;
viewBack.frame = loadiPad;
}
[self.window addSubview:loadView];
}
-(void) hideLoadingView {
[loadView removeFromSuperview];
}
declare this methods in you APPdelegate class so you can call it from any view in your code.
here i have set a view over the window not in view this surelu solve your problem!!!!
Related
I saw a this question and answer and I tried a few options but non worked.
I would like to create a UIPickerView like the one below, (fixed labels inches and feet) but those wouldn't appear:
I create the UIImagePicker like this:
- (void)viewDidLoad
{
_picker = [[UIPickerView alloc] init];
CGRect pickerFrame = CGRectMake(0, 0, 200, 216);
pickerView.frame = pickerFrame;
pickerView.userInteractionEnabled = YES;
pickerView.dataSource = self;
pickerView.hidden = YES;
pickerView.delegate = self;
pickerView.showsSelectionIndicator = YES;
[self.view addSubview:pickerView];
[textField setInputView:pickerView];
textField.delegate = self;
[pickerView removeFromSuperview];
_picker.hidden = YES;
}
- (BOOL) textFieldShouldBeginEditing:(UITextView *)textView
{
if (textView.tag==1){ //field for the uipickerview
_picker.hidden = NO;
[self addPickerLabel:#"Feet" rightX:114 top:342 height:21];
[self addPickerLabel:#"Inches" rightX:241 top:342 height:21];
}
return YES;
}
- (void)addPickerLabel:(NSString *)labelString rightX:(CGFloat)rightX top:(CGFloat)top height:(CGFloat)height {
#define PICKER_LABEL_FONT_SIZE 18
#define PICKER_LABEL_ALPHA 0.7
UIFont *font = [UIFont boldSystemFontOfSize:PICKER_LABEL_FONT_SIZE];
CGFloat x = rightX - [labelString sizeWithFont:font].width;
// White label 1 pixel below, to simulate embossing.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x, top + 1, rightX, height)];
label.text = labelString;
label.font = font;
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
label.opaque = NO;
label.alpha = PICKER_LABEL_ALPHA;
[_picker addSubview:label];
// Actual label.
label = [[UILabel alloc] initWithFrame:CGRectMake(x, top, rightX, height)];
label.text = labelString;
label.font = font;
label.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor clearColor];
label.opaque = NO;
label.alpha = PICKER_LABEL_ALPHA;
[_picker addSubview:label];
}
The picker appears, but without the fixed labels of inches and feet.
What is wrong?
Move this lines to viewDidLoad and try it.Labels need to be added
once.Not always when textfield did begin editing
[self addPickerLabel:#"Feet" rightX:114 top:342 height:21];
[self addPickerLabel:#"Inches" rightX:241 top:342 height:21];
Log the frame of both the label and set it correct if it appears wrong
NSLog(#"%#",NSStringFromCGRect(label.frame));
Your UIPickerView has height of 216, but you put the labels at height 342. This might be the reason you can't see them.
Edit:
Try replacing the lines where you make the labels to
[self addPickerLabel:#"Feet" rightX:114 top:98 height:21];
[self addPickerLabel:#"Inches" rightX:241 top:98 height:21];
I used the already implemented great component:
https://github.com/brunow/ActionSheetPicker2
Which provides a multicolumn picker view and I simply changed the text and the amount of columns
My app's UIScrollView Sliding automatic will bounce back,what can i do?
I do not want!
my code below:
- (void)initScrollView {
// a page is the width of the scroll view
sv = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 96, 320, 300)];
sv.contentSize = CGSizeMake(sv.frame.size.width * 3, sv.frame.size.height* 2);
sv.pagingEnabled = YES;
sv.clipsToBounds = YES;
sv.showsHorizontalScrollIndicator = NO;
sv.showsVerticalScrollIndicator = YES;
sv.scrollsToTop = NO;
sv.directionalLockEnabled = YES;
sv.delegate = self;
[self.view addSubview:sv];
currentPage = 0;
pageControl.numberOfPages = 3;
pageControl.currentPage = 0;
pageControl.backgroundColor = [UIColor clearColor];
[self createAllEmptyPagesForScrollView];
}
- (void)createAllEmptyPagesForScrollView {
tapView1 = [[UIView alloc]init];
tapView1.backgroundColor = [UIColor clearColor];
tapView1.frame = CGRectMake(320*0, 0, 320, sv.frame.size.height);
tapView2 = [[UIView alloc]init];
tapView2.backgroundColor = [UIColor clearColor];
tapView2.frame = CGRectMake(320*1, 0, 320, sv.frame.size.height);
tapView3 = [[UIView alloc]init];
tapView3.backgroundColor = [UIColor clearColor];
tapView3.frame = CGRectMake(320*2, 0, 320, sv.frame.size.height);
[sv addSubview:tapView1];
[sv addSubview:tapView2];
[sv addSubview:tapView3];
}
i konw why I slide up automatically bounce back,my code have problem!Not bove code!thanks everyone!
Hello all,
I have to add one more view in cell of GMGridView. But i am unable to do this because i have to drag my label from view to view1.
My code is :
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView1 cellForItemAtIndex:(NSInteger)index
{
// set size based on orientation
CGSize size = [self GMGridView:gridView sizeForItemsInInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
GMGridViewCell *cell = [gridView dequeueReusableCell];
if (!cell)
{
cell = [[[GMGridViewCell alloc]init]autorelease];
//one view
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
view.backgroundColor = [UIColor redColor];
view.layer.masksToBounds = NO;
view.layer.cornerRadius = 2;
cell.contentView = view;
//another view
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 80, size.width, size.height)];
view1.backgroundColor = [UIColor yellowColor];
view1.layer.masksToBounds = NO;
view1.layer.cornerRadius = 2;
cell.contentView = view1;
}
[[cell.contentView subviews] makeObjectsPerformSelector:#selector(removeFromSuperview)];
// allocate label
UILabel *label = [[UILabel alloc] initWithFrame:cell.contentView.bounds];
label.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
label.text = (NSString *)[self.currentData objectAtIndex:index];
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor blackColor];
label.font = [UIFont boldSystemFontOfSize:20];
[cell.contentView addSubview:label];
return cell;
}
height of cell is 200. but still it shows only one view.
Loading Two types of Cell in GMGridView
This is your Solution, it works as charm..
First Do this Exactly
-(void)prepareExhibitor
{
NSInteger spacing = 1.0;
CGRect rect=self.view.frame;
rect.origin=CGPointMake(0, 0);
self.gmGridView = [[GMGridView alloc] initWithFrame:rect];
self.gmGridView.backgroundColor = [UIColor clearColor];
self.gmGridView.centerGrid=NO;
self.gmGridView.style = GMGridViewStylePush;
self.gmGridView.layoutStrategy = [GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutHorizontal];
self.gmGridView.showsHorizontalScrollIndicator=FALSE;
self.gmGridView.clipsToBounds=YES;
self.gmGridView.itemSpacing = spacing;
self.gmGridView.minEdgeInsets = UIEdgeInsetsMake(0,30, 0, 0);
[self.viewNewsHeadline addSubview:self.gmGridView];
self.gmGridView.actionDelegate = self;
self.gmGridView.dataSource = self;
self.gmGridView.mainSuperView = self.superView;
}
Then Write this accordingly as per your Code
- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index
{
GMGridViewCell *cell = [gridView dequeueReusableCell];
NewsCell_iPad *view;
UIViewController *controller;
if (!cell)
{
// [self removeGrid];
cell = [[GMGridViewCell alloc] init];
if(index%2==0)
{
controller=[[UIViewController alloc] initWithNibName:#"NewsCellTypeA_iPad" bundle:nil];
}
else
{
controller=[[UIViewController alloc] initWithNibName:#"NewsCellTypeB_iPad" bundle:nil];
}
if(!view)
{
view=(NewsCell_iPad *)controller.view;
}
cell.layer.masksToBounds = NO;
cell.contentView = view;
}
NewsCell_iPad *newsView=(NewsCell_iPad *)cell.contentView;
newsView.news=[self.arrNews objectAtIndex:index];
[self hideGradientBackground:newsView.webViewDetailedNews];
[newsView downloadImage];
[newsView loadWebView];
// NSLog(#"cell=%d ,arr image index=%#",index,[self.arrNews objectAtIndex:index]);
return cell;
}
https://github.com/nicklockwood/iCarousel/issues/278
I am going to use the iCarousel to show the images linearly.
These images will be gotten dynamically.
Assume that there are 2 images.
But when I update iCarousel, there are also 2 images in background as following image.
While debugging code, I found that viewForItemAtIndex function is called 2 times after I called reloadData function.
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
So there are 4 images in iCarousel.
How to prevent to be called 2 times?
Please help me to fix this problem asap.
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UIImageView *puzzlePhoto = nil;
UIImageView *puzzleBG = nil;
UILabel *label = nil;
if (view == nil)
{
view = [[UIImageView alloc] init];
view.frame = CGRectMake(0, 0, 128, 112);
view.backgroundColor = [UIColor clearColor];
view.layer.doubleSided = NO;
puzzlePhoto = [[UIImageView alloc] initWithFrame:CGRectMake(46, 48, 40, 40)];
//! get friend's photo
FForesight *foresightCurrent = (carousel == self.icGameOnwhoAREus) ? [controller.gameManager.m_arrayStartedForesights objectAtIndex:index] : [controller.gameManager.m_arrayEndedForesights objectAtIndex:index];
UIImage *imgPuzzle = [foresightCurrent getPuzzleImage];
if (imgPuzzle)
puzzlePhoto.image = imgPuzzle;
else
puzzlePhoto.image = [UIImage imageNamed:#"puzzle background_small.png"];
puzzleBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 128, 112)];
if (((foresightCurrent.m_intStage & FForesightStage_First) && !foresightCurrent.m_FCreatedByFriend) ||
((foresightCurrent.m_intStage & FForesightStage_Second) && foresightCurrent.m_FCreatedByFriend))
puzzleBG.image = [UIImage imageNamed:#"multi_game_one_item_bg_me.png"];
else
puzzleBG.image = [UIImage imageNamed:#"multi_game_one_item_bg.png"];
//! get friend name
FUser *userFriend = foresightCurrent.m_userFriend;
label = [[UILabel alloc] initWithFrame:CGRectMake(32, 32, 68, 16)];
label.text = userFriend.m_strName;
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:10];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor colorWithRed:205.0f/256 green:55.0f/256 blue:2.0f/255 alpha:1];
[view addSubview:puzzlePhoto];
[view addSubview:puzzleBG];
[view addSubview:label];
}
return view;
}
The problem is almost certainly due to the views being recycled incorrectly. Views are re-used with different indexes, you you should never set index-specific properties in your view creation code. Here is the correct way to set up your item view:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UIImageView *puzzlePhoto = nil;
UIImageView *puzzleBG = nil;
UILabel *label = nil;
const NSInteger puzzlePhotoTag = 1;
const NSInteger puzzleBGTag = 2;
const NSInteger labelTag = 3;
if (view == nil)
{
//*************************************************
//do setup that is the same for every item view here
//*************************************************
view = [[UIImageView alloc] init];
view.frame = CGRectMake(0, 0, 128, 112);
view.backgroundColor = [UIColor clearColor];
view.layer.doubleSided = NO;
puzzlePhoto = [[UIImageView alloc] initWithFrame:CGRectMake(46, 48, 40, 40)];
puzzlePhoto.tag = puzzlePhotoTag;
[view addSubview:puzzlePhoto];
puzzleBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 128, 112)];
puzzleBG.tag = puzzleBGTag;
[view addSubview:puzzleBG];
label = [[UILabel alloc] initWithFrame:CGRectMake(32, 32, 68, 16)];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:10];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor colorWithRed:205.0f/256 green:55.0f/256 blue:2.0f/255 alpha:1];
label.tag = labelTag;
[view addSubview:label];
}
else
{
//get references to subviews
puzzlePhoto = (UIImageView *)[view viewWithTag:puzzlePhotoTag];
puzzleBG = (UIImageView *)[view viewWithTag:puzzleBGTag];
label = (UILabel *)[view viewWithTag:labelTag];
}
//*************************************************
//do setup that is different depending on index here
//*************************************************
//! get friend's photo
FForesight *foresightCurrent = (carousel == self.icGameOnwhoAREus) ? [controller.gameManager.m_arrayStartedForesights objectAtIndex:index] : [controller.gameManager.m_arrayEndedForesights objectAtIndex:index];
UIImage *imgPuzzle = [foresightCurrent getPuzzleImage];
if (imgPuzzle)
puzzlePhoto.image = imgPuzzle;
else
puzzlePhoto.image = [UIImage imageNamed:#"puzzle background_small.png"];
if (((foresightCurrent.m_intStage & FForesightStage_First) && !foresightCurrent.m_FCreatedByFriend) || ((foresightCurrent.m_intStage & FForesightStage_Second) && foresightCurrent.m_FCreatedByFriend))
puzzleBG.image = [UIImage imageNamed:#"multi_game_one_item_bg_me.png"];
else
puzzleBG.image = [UIImage imageNamed:#"multi_game_one_item_bg.png"];
//! get friend name
FUser *userFriend = foresightCurrent.m_userFriend;
label.text = userFriend.m_strName;
return view;
}
As for the scrolling inertia problem, if you're still seeing that after applying this fix, file a separate bug report on the github page.
I solved this problem by performing reloadData on mainThread
[carousel performSelectorOnMainThread:#selector(reloadData) withObject:nil waitUntilDone:YES];
Is there a way to rotate an UIPickerView?
//example code placed in view did Load
[super viewDidLoad];
myPicker.delegate = self;
myPicker.dataSource = self;
myPicker.showsSelectionIndicator =YES;
myPicker.backgroundColor = [UIColor blackColor];
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2);
//original settings
//rotate = CGAffineTransformScale(rotate, 0.1, 0.8);
rotate = CGAffineTransformScale(rotate, 0.2, 1.65);
[self.myPicker setTransform:rotate];
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:#"155", #"165", #"175",
#"185", #"195", #"205", #"215", nil];
self.pickerData = array;
[array release];
NSInteger TOTALITEM = [pickerData count];
UILabel *theview[TOTALITEM-1]; // + 1 for the nil
for (int i=1;i<=TOTALITEM-1;i++) {
theview[i] = [[UILabel alloc] init];
theview[i].text = [NSString stringWithFormat:#"%d",i];
theview[i].textColor = [UIColor blackColor];
theview[i].frame = CGRectMake(0,0, 25, 25);
theview[i].backgroundColor = [UIColor clearColor];
theview[i].textAlignment = UITextAlignmentCenter;
theview[i].shadowColor = [UIColor whiteColor];
theview[i].shadowOffset = CGSizeMake(-1,-1);
theview[i].adjustsFontSizeToFitWidth = NO;
UIFont *myFont = [UIFont fontWithName:#"Helvetica" size:30];
[theview[i] setFont:myFont];
}
CGAffineTransform rotateItem = CGAffineTransformMakeRotation(-3.14/2);
rotateItem = CGAffineTransformScale(rotateItem, .5, 5);
for (int j=1;j<=TOTALITEM-1;j++) {
theview[j].transform = rotateItem;
}
pickerData = [[NSMutableArray alloc] init];
for (int j=1;j<=TOTALITEM-1;j++) {
[pickerData addObject:theview[j]];
}
You can rotate a UIPickerView by applying a transform to a view containing it, much like I suggest in my answer here for scaling the picker.
Are you looking for - (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated?
Or do you mean that you want to rotate the whole control 90 degrees, thus having wheels that spin to the left and right?