我制作了一个自定义标签栏,其中一个延伸到栏外.有一条线与中心标签栏重叠.无论如何我可以摆脱这个或隐藏吗?

要做到这一点,我只需设置标签栏图像:
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
tabBarItem1.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
tabBarItem3.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
[tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"scheduleTabBarImageSel.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"scheduleTabBarImage.png"]];
[tabBarItem3 setFinishedSelectedImage:[UIImage imageNamed:@"favoritesTabBarImageSel.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"favoritesTabBarImage.png"]];
[tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"searchTabBarImageSel.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"searchTabBarImage.png"]];
Run Code Online (Sandbox Code Playgroud)
知道如何隐藏线路吗?谢谢
我的桌面视图中有一个按钮,在点击后会发生变化.
在我的cellforrowatindexpath中,我有
[cell.graphicButton addTarget:self action:@selector(changeGraphic:)forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)
应该调用changeGraphic(更改图形).调用成功,但在changeGraphic中,图像不会改变.
- (IBAction)changeGraphic:sender
{
buttonState++;
// button state is an int, im not using BOOl because I have more than 2 images to change from, but for this question i only included 2
if(buttonState == 2){
buttonState = 0;
}
// 1 = travel time 2 =activity time 3 = total time
if (buttonState == 0) {
[cell.vicinitimeGraphicButton setBackgroundImage:[UIImage imageNamed:@"travelDistanceGraphicGreen.png"] forState:UIControlStateNormal];
}
if (buttonState == 1) {
[cell.vicinitimeGraphicButton setBackgroundImage:[UIImage imageNamed:@"activityTimeGraphicGreen.png" ] forState:UIControlStateNormal];
}
[self.tableView beginUpdates]; …Run Code Online (Sandbox Code Playgroud) 我试图在iOS中解析mapquest地理编码json,但NSJSONSterilization返回null.我检查了在线json检查器,看起来网址实际上是一个json.
这是代码 NSJSONSerialization
if(geocodeResponseData)
{
NSLog(@"there is response data");
//this is logged.
}
NSDictionary *mapQuestReponse = [NSJSONSerialization
JSONObjectWithData:geocodeResponseData
options:kNilOptions
error:&error];
NSLog(@"mapquestreponse %@", mapQuestReponse);
Run Code Online (Sandbox Code Playgroud)
这是JSON为解析而返回的URL.
http://www.mapquestapi.com/geocoding/v1/batch?key=API----KEY----HIDDEN----&callback=renderBatch&outFormat=json&location=14443%20C%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=14510%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=14550%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=14515%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=1480%20S%20De%20Anza%20Blvd,San%20Jose,%20CA%2095129&location=1600%20S%20De%20Anza%20Blvd,San%20Jose,%20CA%2095129&location=18486%20Prospect%20Rd,San%20Jose,%20CA%2095070&location=14572%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=5210%20Prospect%20Rd,San%20Jose,%20CA%2095129&location=1600%20S%20De%20Anza%20Blvd,San%20Jose,%20CA%2095106&location=14480%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=1818%20Saratoga%20Ave,San%20Jose,%20CA%2095129&location=18562%20Prospect%20Rd,Saratoga,%20CA%2095070&location=14560%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=14420%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=1075%20S%20De%20Anza%20Blvd,Cupertino,%20CA%2095129&location=18802%20Cox%20Ave,Saratoga,%20CA%2095070&location=6154%20Bollinger%20Rd,San%20Jose,%20CA%2095129&location=14555%20Big%20Basin%20Way,Saratoga,%20CA%2095070&location=14000%20Fruitvale%20Ave,Saratoga,%20CA%2095070
Run Code Online (Sandbox Code Playgroud)
是因为回来NULL了utf-8吗?提前致谢
我存储UIImage在一个NSDictionary,然后使NSDictionary在应用中的另一个地方.gridImages是一个NSMutableArray
NSDictionary *pageDict = [pageArray objectAtIndex:0];
UIImage *pageImage = [pageDict objectForKey:@"image"];
[gridImages addObject:pageImage];
Run Code Online (Sandbox Code Playgroud)
pagedict返回
{
class = is;
image = "<UIImage: 0x14e20e10>";
name = kaka;
page = 64;
}
Run Code Online (Sandbox Code Playgroud)
这大概是我做的
UIImage *pageImage = [pageDict objectForKey:@"image"];
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试将UIImage添加到数组时,我收到此错误:
-[UIImage stringByDeletingPathExtension]: unrecognized selector sent to instance 0x14e20e10
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
编辑:
对于NSDictionary,我尝试存储UIImageas NSData:
NSData *imageData = UIImagePNGRepresentation(textbookImage);
[pageDict setObject:imageData forKey:@"image"];
[pageDict setObject:textbookName forKey:@"name"];
[pageDict setObject:page forKey:@"page"];
[pageDict setObject:nameOfClass forKey:@"class"];
Run Code Online (Sandbox Code Playgroud)
并解析它像这样:
NSData *imageData = …Run Code Online (Sandbox Code Playgroud) 我有一个水平的集合视图,其代码用于突出显示/为所选单元格着色.它突出显示所选的单元格,但之后每5个单元格也会突出显示.知道发生了什么事吗?
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
for(int x = 0; x < [cellArray count]; x++){
UICollectionViewCell *UnSelectedCell = [cellArray objectAtIndex:x];
UnSelectedCell.backgroundColor = [UIColor colorWithRed:0.2 green:0.5 blue:0.8 alpha:0.0];
}
UICollectionViewCell *SelectedCell = [cellArray objectAtIndex:indexPath.row];
SelectedCell.backgroundColor = [UIColor colorWithRed:0.2 green:0.5 blue:0.8 alpha:1.0];
cellSelected = indexPath.row;
NSLog(@"%i", cellSelected);
}
Run Code Online (Sandbox Code Playgroud) 我知道这个问题已被多次提出,但所有这些问题都指出连接必须在不同的线程上.
-(void)distanceMatrix{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:distanceMatrixURL]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10];
connection2 = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
[connection2 scheduleInRunLoop:[NSRunLoop mainRunLoop]
forMode:NSDefaultRunLoopMode];
NSLog(@"Is%@ main thread", ([NSThread isMainThread] ? @"" : @" NOT"));
[connection2 start];
if (connection2)
{
responseData2 = [NSMutableData data];
connectionIsActive = YES;
} else {
NSLog(@"connection failed");
}
}
- (void)connection2:(NSURLConnection *)connection2 didReceiveResponse:(NSURLResponse *)response
{NSLog(@"recieved response");
[responseData2 setLength:0];
}
- (void)connection2:(NSURLConnection *)connection2 didReceiveData:(NSData *)data
{
[responseData2 appendData:data];
}
- (void)connection2:(NSURLConnection *)connection2 didFailWithError:(NSError *)error
{
connectionIsActive = NO;
NSLog(@"failed!!");
} …Run Code Online (Sandbox Code Playgroud) 我有一个视图1.导航栏2.UITableView 3. UITextView.
当我开始编辑textView时,会出现一个键盘,我需要为TextView和TableView设置动画.我已经实现了:https://stackoverflow.com/a/8704371/1808179,但这会动画整个视图,覆盖导航栏.
我尝试单独动画textView,如:
- (void)keyboardWillShow:(NSNotification*)notification
{
CGRect chatTextFieldFrame = CGRectMake(chatTextField.frame.origin.x,chatTextField.frame.origin.y-218,chatTextField.frame.size.width,chatTextField.frame.size.height);
[UIView animateWithDuration:0.5 animations:^{ chatTextField.frame = chatTextFieldFrame;}];
}
Run Code Online (Sandbox Code Playgroud)
但它没有动画,也不会与TableView同步动画.
在不覆盖导航栏的情况下,为tableView和textView设置动画的最佳方法是什么?
如何解除模态然后立即推送另一个视图?
我在didSelectRowAtIndexPath中添加此代码:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ChatTableViewController *chatVC = (ChatTableViewController*)[storyboard instantiateViewControllerWithIdentifier:@"chatVC"];
[self dismissViewControllerAnimated:YES completion:^{
[[self navigationController] pushViewController:chatVC animated:YES];
}];
Run Code Online (Sandbox Code Playgroud)
模态视图解散,但之后没有任何反应.有任何想法吗?
ios ×7
objective-c ×6
uitableview ×2
xcode ×2
delegates ×1
image ×1
line ×1
mapquest ×1
nsarray ×1
nsdictionary ×1
null ×1
parsing ×1
segue ×1
storyboard ×1
uibutton ×1
uiimage ×1
uitabbar ×1
uitextfield ×1