我有一个模型预订,其中有一个历史.像这样,我使用django_simple_history
class Booking(CreatedAtAbstractBase):
history = HistoricalRecords()
Run Code Online (Sandbox Code Playgroud)
我使用管理命令来完成任务.我想在预订时预取历史记录
booking_p_history = Booking.history.filter(s_id=6).order_by(
'updated_at').first()
booking_obj_list = Booking.objects.select_related(...) \
.prefetch_related(
Prefetch('booking_history', queryset=booking_p_history, to_attr='driver_pickup_history')
,'booking_history') \
.filter(...)
Run Code Online (Sandbox Code Playgroud)
如何在预取中使用简单的历史记录?
我有一个OTP屏幕,我必须在4个Diff TextFields中输入4位数密码的OTP,场景如下:
我已经管理了高达70%的工作,但只有当用户输入所有textField时,后退空间才有效.我正在粘贴我的代码.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
// This allows numeric text only, but also backspace for deletes
if (string.length > 0 && ![[NSScanner scannerWithString:string] scanInt:NULL])
return NO;
NSUInteger oldLength = [textField.text length];
NSUInteger replacementLength = [string length];
NSUInteger rangeLength = range.length;
NSUInteger newLength = oldLength - rangeLength + replacementLength;
// This 'tabs' to next field when entering digits
if (newLength == 1) {
if (textField == _pin1)
{
[self performSelector:@selector(setNextResponder:) withObject:_pin2 afterDelay:0];
}
else …
Run Code Online (Sandbox Code Playgroud) 我有UITabBarController
一个UINavigationController
拿着一个UIViewController
根视图控制器.
当点击其中一个按钮时UIViewController
,我按下一个常规聊天窗口UIViewController
(用TableView +输入视图)结束隐藏底部标签栏.(使用"按下时隐藏底栏"标志)
在故事板中,我UIView
向VC 添加了一个看起来像底栏的常规子类,我使用自动布局将其固定到VC视图的底部.
我推VC时的问题需要一秒钟才能将此视图固定到底部,看起来像自动布局将其固定到底部,就像标签栏没有隐藏一样,一秒后它就会识别出标签栏是隐藏的将其移动到视图的真实底部.
有关清晰信息,请查看此屏幕截图
我也在添加我的View层次结构......
实际上我正在尝试使用PageViewController填充图库.我成功地在视图中添加了滚动图像但是,我在页面View Controller中使用了Next和Previous按钮,但是我使用了这行代码.
- (IBAction)previousButtonPressed:(id)sender {
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil];
}
- (IBAction)nextButtonPressed:(id)sender {
PageContentViewController *startingViewController = [self viewControllerAtIndex:+1];
NSArray *viewControllers = @[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
因为我在- (IBAction)nextButtonPressed:(id)发送者使用了viewControllerAtIndex:+1我只是在第一次点击按钮动作时才使按钮动作正常工作.提前致谢
我试图实现本地通知到我的应用程序,我实现了本地通知,但问题是.... 当我的应用程序在前台时,我没有收到通知BANNER和SOUND.但是当我的应用程序处于后台时,它运行良好.如何将通知横幅和声音带到前台..这可能吗?
这是我的一段代码......
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Handle launching from a notification
UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (locationNotification) {
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
}
}
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
if (application.applicationState == UIApplicationStateActive ) {
NSLog(@"it entered active push");
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.userInfo = userInfo;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertBody = userInfo[@"aps"][@"alert"][@"body"];
localNotification.alertLaunchImage= userInfo[@"acme1"];
localNotification.fireDate = [NSDate date];
localNotification.applicationIconBadgeNumber = …
Run Code Online (Sandbox Code Playgroud) ios ×4
objective-c ×4
autolayout ×1
button ×1
django ×1
prefetch ×1
python ×1
uitextfield ×1
xcode7 ×1