我遇到了几个博客,告诉我们如何做到这一点,但我不确定苹果是否接受或拒绝这些应用程序.我经历的链接如下:
请各位朋友帮我解决一下如何做到这一点的简单解决方案?
我开始知道有一个委托函数:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 3;
}
Run Code Online (Sandbox Code Playgroud)
但是如何实现这一点以及如何选择具有复选标记的特定行,因为它是在Apple的标准邮件应用程序中完成的?
我正在使用google places API for autoComplete小部件.我正在使用swift在ios 9+中显示全屏控制.我正在添加文档中给出的完整控件.
我添加了文档中显示的代码.现在我想将searchBar文本颜色更改为whiteColor.
所以我尝试了这个
UITextField.appearanceWhenContainedInInstancesOfClasses([UISearchBar.self]).textColor = UIColor.whiteColor()
Run Code Online (Sandbox Code Playgroud)
但我没有得到理想的行为.以下是截图
这已在Docs中给出
https://developers.google.com/places/ios-api/autocomplete#use_a_table_data_source
但这不起作用.对此我需要帮助.
我有一个自定义单元格,并添加了一个标签和图像,我的表格中有4行,每行有不同的图像,每行打开一个不同的视图控制器,所以,现在我需要点击一个特定的行我希望图像改变,我尝试这样做,但它不起作用,所以请帮助我.
if(indexPath.row == 0)
{
if(cell.selected == true)
{
UIImage *cellImage = [UIImage imageNamed:@"abc.png"];
cell.icon.image = cellImage;
}
else
{
UIImage *cellImage = [UIImage imageNamed:@"abc.png"];
cell.icon.image = cellImage;
}
}
Run Code Online (Sandbox Code Playgroud)
问候Ranjit
我正在使用UIBezeirPath,并且在我的drawRect方法中,我采用硬编码颜色以下面的方式为我的路径(行)设置setStroke
- (void)drawRect:(CGRect)rect
{
[[UIColor redColor] setFill];
for (UIBezierPath *_path in pathArray)
{
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,并为我绘制的路径(线)设置红色.现在,当我从颜色选项中选择不同颜色时,假设我选择蓝色,现在当我开始绘制路径时,颜色为蓝色,但之前绘制的红线也变为蓝色.这就是整个问题
下面是我的代码如何设置不同的颜色
- (void)drawRect:(CGRect)rect
{
if(changecolor)
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
strokeColor = appDelegate.color;
NSLog(@"%@",strokeColor);
SEL blackSel = NSSelectorFromString(strokeColor);
UIColor* tColor = nil;
if ([UIColor respondsToSelector: blackSel])
tColor = [UIColor performSelector:blackSel];
[tColor setStroke];
[tColor setFill];
}
else
{
[[UIColor redColor] setStroke];
[[UIColor redColor] setFill];
for (UIBezierPath *_path in pathArray)
{
[_path strokeWithBlendMode:kCGBlendModeNormal alpha:1.0];
}
}
}
Run Code Online (Sandbox Code Playgroud)
我是以正确的方式行事,还是我错过了什么.请帮帮我
问候Ranjit
我正在使用iOS绘图,我的代码正常工作,绘图工作正常,现在我已经实现了撤销和重做功能,但是发生了什么,假设我画了两行然后按下撤销按钮,然后是第一行绘制正在变得模糊,我不明白它为什么会发生,下面是我的撤消代码.
-
(void)redrawLine
{
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
NSDictionary *lineInfo = [lineArray lastObject];
curImage = (UIImage*)[lineInfo valueForKey:@"IMAGE"];
UIGraphicsEndImageContext();
[self setNeedsDisplayInRect:self.bounds];
[self setNeedsDisplay];
}
-(void)undoButtonClicked
{
if([lineArray count]>0){
NSMutableArray *_line=[lineArray lastObject];
[bufferArray addObject:[_line copy]];
[lineArray removeLastObject];
drawStep = UNDO;
[self redrawLine];
}
}
- (void)drawRect:(CGRect)rect
{
switch (drawStep) {
case DRAW:
{
[curImage drawAtPoint:CGPointMake(0, 0)];
CGPoint mid1 = midPoint(previousPoint1, previousPoint2);
CGPoint mid2 = midPoint(currentPoint, previousPoint1);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.layer renderInContext:context];
CGContextMoveToPoint(context, mid1.x, mid1.y);
CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y);
CGContextSetLineCap(context, …Run Code Online (Sandbox Code Playgroud) 我正在使用coreData,具有一对多的实现,我有一个文件夹实体和一个文件实体.文件夹可以包含许多文件,依此类推.
所以,我有两个ViewControllers,FolderViewController和FileViewController,它们分别包含文件夹和文件.现在我有一个modalView,可以从文件夹和文件viewcontroller访问.在这个VC中,我有一个重置所有数据的按钮.所以,当我点击这个时,我想要重置所有数据.
我使用了这段代码,这个函数是用appdelegate.m编写的,并从我的VC中调用.
- (void)resetToDefault
{
NSError * error;
// retrieve the store URL
NSURL * storeURL = [[__managedObjectContext persistentStoreCoordinator] URLForPersistentStore:[[[__managedObjectContext persistentStoreCoordinator] persistentStores] lastObject]];
// lock the current context
[__managedObjectContext lock];
[__managedObjectContext reset];//to drop pending changes
//delete the store from the current managedObjectContext
if ([[__managedObjectContext persistentStoreCoordinator] removePersistentStore:[[[__managedObjectContext persistentStoreCoordinator] persistentStores] lastObject] error:&error])
{
// remove the file containing the data
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error];
//recreate the store like in the appDelegate method
[[__managedObjectContext persistentStoreCoordinator] addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error];//recreates the persistent …Run Code Online (Sandbox Code Playgroud) 我正在做一个绘图应用程序,我正在尝试平滑我用手指绘制的线.为此我使用"quadCurveToPoint"功能.但是,我没有做对.
以下是我的代码:
- (void) drawRect:(CGRect)rect
{
[path stroke];
}
- (id) initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
self.multipleTouchEnabled = NO;
path = [UIBezierPath bezierPath];
path.lineWidth = IS_IPAD? 2.0f : 1.0f;
return self;
}
- (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent *) event
{
UITouch *touch = [touches anyObject];
m_previousPoint1 = [touch locationInView:self];
m_previousPoint2 = [touch locationInView:self];
m_currentPoint = [touch locationInView:self];
}
//Find the midpoint
CGPoint midPoint(CGPoint p1, CGPoint p2)
{
return CGPointMake((p1.x + p2.x) * 0.5, (p1.y + p2.y) * …Run Code Online (Sandbox Code Playgroud) 我的第一个视图上有两个按钮,所以当我点击其中一个按钮时,视图会发生变化,所以我有两个图像用于默认状态,一个用于选择状态,首先我尝试使用xib,进入属性和改变状态,然后选择正确的图像,当我构建和运行我的代码时,在图像上不会改变..
所以我通过代码这样做了
- (IBAction) handleButton:(id)sender
{
UIButton *button = (UIButton*)sender;
int tag = [button tag];
switch (tag)
{
case BUTTON_1:
if ([m_Button1 isSelected])
{
[m_Button2 setImage:[UIImage imageNamed:@"image.png"] forState:UIControlStateNormal];
[m_Button1 setSelected:NO];
}
else
{
[m_Button1 setImage:[UIImage imageNamed:@"image_pressed.png"] forState:UIControlStateSelected];
[m_Button1 setSelected:YES];
}
[self displaymethod1];
break;
case BUTTON_2:
[self displaymethod2];
break;
default:
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这里图像变化,当我点击它,我去不同的视图..当我再次回到我的第一个视图,按钮仍处于选定模式..所以我该如何解决这个问题..
等待你的回复
我正在使用DatePicker,我想对用户选择日期选择器设置特定限制,我想要
start day of the week - tuesday
end day of the week - saturday
start time - 16:00:00
end time - 19:00:00
Run Code Online (Sandbox Code Playgroud)
所以朋友请分享您对此的看法.
我们是否应该使用NSDateComponents.
在我看来我有4个文本字段,我已经从xib拖了它,
所以当我点击前三个文本字段时,我想要打开一个键盘,当我点击第四个文本字段时,我只想打开一个UIPickerView
下面我写了代码,它为所有文本字段打开UIPickerView.
- (void)textFieldDidBeginEditing:(UITextField *)textField{
[textField resignFirstResponder];
[self uiPickerPopUpDisplay];
}
Run Code Online (Sandbox Code Playgroud)
所以朋友们请帮帮我,我该怎么办呢
谢谢和问候Ranjit
我正在使用UIlocalnotifications,所以每当弹出一个通知,并且用户点击它时,我打开ViewController,所以每当我的应用程序处于后台时,当弹出通知,当用户点击它或应用程序图标时,我能够显示ViewController.
但是每当用户从后台杀死应用程序时,当通知发生时,如果他点击通知,我就能够显示ViewController,但是如果我点击应用程序图标,我就无法显示ViewController
以下是我的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (locationNotification) {
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
AlarmViewController *alarmView = [[AlarmViewController alloc]initWithNibName: @"AlarmViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:alarmView];
[self.window.rootViewController presentViewController:navController animated:YES completion:nil];
}
}
Run Code Online (Sandbox Code Playgroud)
我试图调试这个问题,我发现的是,每当我点击应用程序图标时,它都没有得到任何本地通知.只有点击通知,我才能获得本地通知.我不知道这是一个错误,或者我是否遗漏了什么.
所以请帮帮我
问候Ranjit.
ios ×10
ios4 ×4
ios-4.2 ×3
iphone ×3
cocoa-touch ×2
ios5 ×2
objective-c ×2
uibezierpath ×2
appdelegate ×1
core-data ×1
drawing ×1
google-maps ×1
ios6 ×1
ios7 ×1
uiappearance ×1
uidatepicker ×1
uikit ×1
uisearchbar ×1