小编Spo*_*ude的帖子

如何在调用-drawRect后在UIView中绘制文本

我有一个iPad应用程序,XCode 4.5,iOS 6.1和Storyboard.我有一个UIView,其中嵌入了两(2)个UIViews.第一个UIView(称为Calendar)位于上半部分,第二个UIView(称为Schedule)位于下半部分.我在上半部分创建一个日历,并绘制一个网格以显示下半部分的时间表.

事件序列是向用户呈现带有日历的场景(完全填写当月)和计划(显示空网格).在日历上点击一天时,该日程表将显示在"日程表"视图中.

-drawRect在用户能够选择要为日程表显示的日期之前,在最初显示场景时调用问题.因为我必须从-drawRect中进行绘图,所以我无法弄清楚如何填写以外的时间表-drawRect.我想知道是否使用setNeedsDisplayInRect : ,会完成我需要做的事情吗?

我已经看了几天SO和谷歌了,发现没有什么能回答这个问题.这不是这个问题的重复,而是一个后续,因为项目已经重新定义.任何想法将不胜感激.

更新:这是我使用setNeedsDisplayInRect的代码:

- (void) drawSchedule  {
    const float rectWidth = 120.0;

    //  draw detail for selected day for each staff member
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
    CGContextSetLineWidth(context, 1.0);
    CGContextSetRGBFillColor(context, 0, 0, 1, 0.3); 

    UIGraphicsBeginImageContext(self.bounds.size);

    //  draw customer name using bounds from CGRectMake
    const float nameFontSize = 12;
    UIFont *hourfont=[UIFont systemFontOfSize: nameFontSize];
    [[UIColor blackColor] set];
    [self setNeedsDisplayInRect: CGRectMake(160.0, 150.0, 120.0, 50.0)];  //  mark as needs …
Run Code Online (Sandbox Code Playgroud)

objective-c cgcontext

2
推荐指数
1
解决办法
3493
查看次数

如何在使用UIDatePicker时禁用键盘但启用UITextField?

这个很难解释,因此请提出您需要的任何问题来澄清问题.我有一个iPad应用程序(XCode 4.2,iOS 6,ARC和Storyboards).

在这个应用程序中,我有一个UIPopover包含UIView两个(2)UITextFields和一个UIDatePicker.(见图).当我去那个场景时,我已经取消选中userInteractionEnabled两个textFields以防止键盘响应,这有效,但不允许UITextField在第一个之后访问另一个.我尝试了[oFinishTime setInputView:oTimePicker];但它需要时间戳并将其移到弹出窗口之外,这是不可接受的.

图像显示2个uiviews和一个datepicker

touchUpInside为每个textField都设置了"有线"事件,但由于未选中UserInteractionEnabled,因此在点击时都不会调用任何事件.如果我可以启用它并在动作事件中设置一个标志,我可以补救这一切.

如何启用这两个功能UITextFields但是阻止键盘显示?我很乐意发布您需要查看的任何相关代码.

xcode uidatepicker uitextfield ios

2
推荐指数
2
解决办法
6512
查看次数

Monotouch:如何在AppDelegate分部类中更新文本字段?

我有一个文本字段(使用IB创建),其中有一个连接到App Delegate的插座.可访问性已启用.

我有一个IAP课程,我需要更新该文本字段.从我的代码中看不出来.

我该怎么做呢?

textfield xamarin.ios

1
推荐指数
1
解决办法
1400
查看次数

C#:如何判断机器的架构

可能重复:
如何使用.net检测Windows 64位平台?

在较低的级别,如何判断特定的机器是64位还是32位?我有一个看起来对64位架构敏感的Firebird d/b,我想验证一下.

c# architecture 64-bit

1
推荐指数
1
解决办法
225
查看次数

在AppDelegate中设置的Singleton在另一个类中分配时会丢失它的值

我有一个iPad应用程序,我试图使用单例.这是.h文件中的代码:

//-------------------------------------------
//--  singleton: timeFormat
@interface SingletonTimeFormat : NSObject  {
}
@property (nonatomic, retain) NSNumber *timeFormat;

+ (id)sharedTimeFormat;
@end
Run Code Online (Sandbox Code Playgroud)

这是.m文件中的代码:

//-------------------------------------------
//--  SingletonTimeFormat
@implementation SingletonTimeFormat  {

}

@synthesize timeFormat;

//--  sharedColorScheme  --
+ (id)sharedTimeFormat  {

static dispatch_once_t dispatchOncePredicate = 0;
__strong static id _sharedObject = nil;
dispatch_once(&dispatchOncePredicate, ^{
    _sharedObject = [[self alloc] init];
});

return _sharedObject;
}

-id) init {
self = [super init];
if (self) {
    timeFormat = [[NSNumber alloc] init];
}
return self;
}

@end
Run Code Online (Sandbox Code Playgroud)

我在AppDelegate中加载了值(12或24)- didFinishLaunchingWithOptions …

singleton objective-c singleton-methods ios7

1
推荐指数
1
解决办法
336
查看次数

- 当弹出窗口仍然可见时,到达[UIPopoverController dealloc]

我有一个类(ViewOpenAppointments),我在其中创建和显示UIPopover.这是在我的.h文件中定义popover的代码:

@interface ViewOpenAppointments : UIView  {

}

@property (nonatomic, retain) UIPopoverController *popoverController;
-(void)createOpenAppointmentsPopover: (UIButton *) obViewOpenAppts;
@end
Run Code Online (Sandbox Code Playgroud)

我在代码中检查了如果弹出窗口可见,则将其关闭.这是代码:

    //  create popover
UIViewController* popoverContent = [[UIViewController alloc] init];
//    UIView *popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 650, 416)];
ViewOpenAppointments *popoverView = [[ViewOpenAppointments alloc]     initWithFrame:CGRectMake(0, 0, 650, 416)];

popoverView.backgroundColor = [UIColor whiteColor];
popoverContent.preferredContentSize = CGSizeMake(650.0, 416.0);

//  create the popover controller
popoverController = [[UIPopoverController alloc]  initWithContentViewController:popoverContent];
popoverController.delegate = (id)self;
[popoverController setPopoverContentSize:CGSizeMake(650, 416) animated:NO];

if ([popoverController isPopoverVisible]) {
    [popoverController dismissPopoverAnimated:YES];
}

[popoverController presentPopoverFromRect:CGRectMake(650, …
Run Code Online (Sandbox Code Playgroud)

objective-c uiviewcontroller uiview uipopover ios7

1
推荐指数
1
解决办法
3125
查看次数

如何在iOS 6中获取默认日历的名称/ ID

我的iPad上有两(2)个日历(iCal)(一个个人,一个用于应用程序).它们与我的iMac同步,仅用于测试.(节省我在特定应用程序日历中输入的时间).

我目前正在编写一个需要访问应用程序日历的应用程序.它是iPad上的主要日历.我试图让Apple的SimpleEKDemo(未经修改)与应用程序的日历一起工作,但到目前为止我甚至不能让它不崩溃,更不用说返回任何东西了.我几个小时以来一直在关注谷歌和SO问题,并决定是时候召唤大枪了.

这是它崩溃的代码:

- (void)viewDidLoad
{
    self.title = @"Events List";

    // Initialize an event store object with the init method. Initilize the array for events.
    self.eventStore = [[EKEventStore alloc] init];

    self.eventsList = [[NSMutableArray alloc] initWithArray:0];

    // Get the default calendar from store.
    self.defaultCalendar = [self.eventStore defaultCalendarForNewEvents];  //  <---- crashes here    --------

    //  Create an Add button
    UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
                                      UIBarButtonSystemItemAdd target:self action:@selector(addEvent:)];
    self.navigationItem.rightBarButtonItem = addButtonItem;
    [addButtonItem release];

    self.navigationController.delegate = self;

    // Fetch today's event on selected calendar …
Run Code Online (Sandbox Code Playgroud)

icalendar objective-c xcode4

0
推荐指数
1
解决办法
6218
查看次数

如何识别从两个可用的UITableView中选择

我有一个UITabView iPad应用程序,使用的XCode 4.5,故事板和iOS 6.我有一个UIView场景,具有两个UITableViews(一个在左上象限,另一个在UIView的下半部).我的问题是我需要确定为numberOfRowsInSectioncellForRowAtIndexPath引用了哪个UITableView .我已经给出了两个UITableViews名称:

图像显示id

我不认为这是正确的,因为当我在numberOfRowsInSection上断点时,它任意选择较低的UITableView(previousAppointments),从不选择上层UITableView(clientList).代码如下:

//------------------------------------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (tableView == clientList)  {
        int y = listOfClients.count;
        return 1;  //  return list of clients          <---------  TODO
    }
    else if(tableView == previousAppointments) {
        return 2;  //  return number of appointments for this client    <------------ TODO
    }

    return 1;
}
Run Code Online (Sandbox Code Playgroud)

我需要能够识别选择哪个UITableView,以便我可以用正确的数据填充它.

我究竟做错了什么?

objective-c ios xcode4.5

0
推荐指数
1
解决办法
914
查看次数

如何获取UITabBarController的现有实例?

我有一个iPad应用程序(XCode 4.6,ios 6.2,ARC和Storyboards).我需要获得UITabBarController的现有实例.这是我的代码,但显然是错的.我该如何纠正?

    UITabBarController *tabBarController = [self.storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
[tabBarController setSelectedIndex:0];
Run Code Online (Sandbox Code Playgroud)

objective-c ios6 xcode4.6

0
推荐指数
1
解决办法
1345
查看次数

使用“NSArray *”类型的表达式初始化“NSMutableArray *”时不兼容的指针类型

这是我的代码导致上述警告:

    NSMutableArray *tbValueArray = [NSArray arrayWithObjects:oServices1.text,
                oServices2.text,oServices3.text,oServices4.text,oServices5.text,oServices6.text,
                oServices7.text,oServices8.text,oServices9.text,oServices10.text,oServices11.text,
                oServices12.text,oServices13.text,oServices14.text,oServices15.text,oServices16.text,
                oServices17.text,oServices18.text,oServices19.text,oServices20.text,oServices21.text,
                oServices22.text,oServices23.text,oServices24.text,nil];
Run Code Online (Sandbox Code Playgroud)

如何更改此设置以删除警告?(我查看了 Google 和 SO,没有发现任何适用的内容)。

objective-c nsmutablearray nsarray

-5
推荐指数
1
解决办法
7956
查看次数