小编Bea*_*red的帖子

如何在 iOS 8 的模态视图控制器中强制纵向方向?

这是我只想以纵向显示的视图控制器的视图控制器代码...

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}

- (BOOL)shouldAutorotate {
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

这就是我如何呈现它...

MyViewController *myVC = [[MyViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myVC];
[self presentViewController:nav animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

如果设备处于横向并且呈现视图控制器,它会正确地自动旋转到纵向。但是,如果您在显示设备后旋转设备,它会自动旋转到设备所处的任何方向。我想在显示后防止自动旋转,并仅对这个视图控制器强制纵向方向。这是一个仅限 iOS8 的应用程序。

在此先感谢您的智慧!

iphone objective-c ios ios8

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

是否有一个很好的C++崩溃报告库,可以很好地与Visual Studio 2005一起使用?

在阅读了之前的讨论这个讨论之后,看起来Crashrpt看起来就像我正在寻找的那样,但它似乎不再被维护,并且在使用它之后,发现它与Visual Studio 2005不兼容.

有人在Visual Studio 2005中使用Crashrpt吗?

如果没有,任何人都可以推荐一个好的C++解决方案来自动化...

  1. 生成详细且可读的崩溃转储和
  2. 将其与任何其他指定的日志文件一起压缩
  3. 通过电子邮件将压缩包发送给开发人员

提前致谢!

c++ crashrpt visual-studio visual-c++-2005 pdb-files

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

简单的XSLT问题:如何在单个标记的末尾添加结束"/"?

我正在自学XSLT,我仍然试图将我的大脑包围在小细节中.我的XSL样式表中有一个模板,看起来像这样......

<td><img src="{normalize-space(image)}"/></td>
Run Code Online (Sandbox Code Playgroud)

产生看起来像这样的XHTML ......

<td><img src="somefile.jpg"></td>
Run Code Online (Sandbox Code Playgroud)

如何更改我的XSL模板以向img标记添加尾部"/",以便XHTML输出看起来像这样......

<td><img src="somefile.jpg"/></td>
Run Code Online (Sandbox Code Playgroud)

另外,为什么模板中的尾部斜杠在输出中被省略?

在此先感谢您的帮助!

xslt xhtml

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

如何获取客户端程序的本地TCP端口和IP地址?

我正准备一个简单的工作项目,并试图熟悉Unix开发环境中套接字编程的基础知识.此时,我有一些基本的服务器端代码和客户端代码设置进行通信.目前,我的客户端代码成功连接到服务器代码,服务器代码向它发送测试消息,然后退出.完善!这正是我想要完成的.现在,我正在使用用于获取有关两个环境(服务器和客户端)的信息的函数.我想获取本地IP地址并动态分配客户端的TCP端口.我发现这样做的功能是getsockname()......

//setup the socket
if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) 
{
   perror("client: socket");
   continue;
}

//Retrieve the locally-bound name of the specified socket and store it in the sockaddr structure
sa_len = sizeof(sa);
getsock_check = getsockname(sockfd,(struct sockaddr *)&sa,(socklen_t *)&sa_len) ;
if (getsock_check== -1) {
    perror("getsockname");
    exit(1);
}

printf("Local IP address is: %s\n", inet_ntoa(sa.sin_addr));
printf("Local port is: %d\n", (int) ntohs(sa.sin_port));
Run Code Online (Sandbox Code Playgroud)

但输出始终为零......

Local IP address is: 0.0.0.0
Local port is: 0
Run Code Online (Sandbox Code Playgroud)

有没有人看到我可能会做的事情或肯定做错了?

非常感谢您的帮助!

c unix sockets

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

运行ASP.NET MVC应用程序时,此端口号http:// localhost:52432 /指定在哪里?

我正在玩ASP.NET MVC,我只是加载了一个空项目并运行它,我的浏览器中的URL是http://localhost:52432/.52432端口号在哪里指定?

在此先感谢您的帮助,我现在就开始研究这个问题了.

asp.net-mvc

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

我的iPad应用程序可能会被应用商店拒绝使用Tapku库吗?

我想使用Tapku库为我的iPad应用程序添加一个日历选择器控件.我是iPhone操作系统开发的新手,在识别第三方工具和代码时,我仍然很生气,这些工具和代码会让我的iPad应用程序从应用程序商店中被拒绝.对于那些使用过Tapku库的人来说,在我的iPad应用程序中使用它会违反任何应用商店规则吗?

非常感谢您的帮助.我现在要继续研究这个问题.

iphone calendar appstore-approval ipad

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

为什么我的数据成功写入iPhone模拟器上的文件,而不是我的设备?

我有以下代码将用户草图数据保存到文件中...

//Auto Save the sketch
NSString *filename = [NSString stringWithFormat:@"%@.png", sketchID];
CGImageRef imageRef = CGBitmapContextCreateImage(paintView.canvas.mBitmapContext);
UIImage* image = [[UIImage alloc] initWithCGImage:imageRef];
NSData* imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:filename atomically:YES];

CGImageRelease(imageRef);
[image release];
Run Code Online (Sandbox Code Playgroud)

SketchID是一个唯一的字母数字值,因此我保存的文件名的示例是"p1.png".我用来读取文件的代码是......

//Load the sketch where the user left off, if there is one
if(fileName != nil)
{
    UIImage* image = [UIImage imageWithContentsOfFile:fileName];    

    if(image != nil)
    {
          .
          .
Run Code Online (Sandbox Code Playgroud)

在模拟器上运行时,此代码似乎工作正常,但是当我在设备上运行它时,无法加载图像.我是iOS开发的新手,我还在学习如何存储文件.我的问题是......

  1. 为什么保存/加载文件在模拟器上工作,而不是设备?
  2. 当我创建我想要保存数据的文件名时,是否还需要在iPhone上包含一个特定目录的路径,以便正确存储数据?或者,当我调用writeToFile:方法时,"p1.png"应该正常工作吗?那imageWithContentsOfFile:方法怎么样?

非常感谢您的帮助!

cocoa-touch objective-c ios

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

Rails 3:如何指定用于特定方法的布局,但是否则使用默认的application.html.erb?

我有一个带有一些方法的控制器,我想对所有这些方法使用默认的application.html.erb布局,除了#list方法.所以我已经在#list方法的控制器顶部声明了特定的布局,就像这样......

class MyController < ApplicationController
   layout "customlayout", :only => [:list]
Run Code Online (Sandbox Code Playgroud)

但似乎现在我已经丢失了该控制器中所有其他方法的默认application.html.erb布局.我错过了什么?

非常感谢你的智慧!

ruby-on-rails

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

为什么我的TabBar按钮不会在iPad上自动显示?

我正在构建一个通用的iOS应用程序,iPad版本使用SplitViewController.在popover视图中,我有一个带有两个按钮的UITabBarController.当它在iPhone上运行时,TabBar按钮正确拉伸以填充视图的整个宽度......

在此输入图像描述

...但是在iPad上,在弹出视图中,按钮不会伸展以填满整个宽度......

在此输入图像描述

我正在以编程方式创建UITabBarController ...

InspectionTabBarViewController *inspectionTabBarVC;
    InspectionListViewController *inspectionListVC;
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

        inspectionListVC = [[InspectionListViewController alloc] initWithSunday:NO];
        inspectionListVC.managedObjectContext = self.managedObjectContext;
        UINavigationController *calendarNavVC = [[UINavigationController alloc] initWithRootViewController:inspectionListVC];
        calendarNavVC.title = @"Calendar";

        InspectionMapViewController *mapViewVC = [[InspectionMapViewController alloc] initWithNibName:@"InspectionMapView_iPhone" bundle:nil];
        UINavigationController *mapdNavVC = [[UINavigationController alloc] initWithRootViewController:mapViewVC];
        mapdNavVC.title = @"Map";

        inspectionTabBarVC = [[InspectionTabBarViewController alloc] init];
        [inspectionTabBarVC addChildViewController:calendarNavVC];
        [inspectionTabBarVC addChildViewController:mapdNavVC];
        self.window.rootViewController = inspectionTabBarVC;
    } 
    else 
    {
        inspectionListVC = [[InspectionListViewController alloc] initWithSunday:NO];
        UINavigationController *calendarNavVC = [[UINavigationController alloc] …
Run Code Online (Sandbox Code Playgroud)

iphone uitabbarcontroller ipad ios

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

如何远程检查RedisCloud DB中的数据?

我正在使用Heroku来托管一个简单的Ruby on Rails测试应用程序来学习如何使用Redis.我正在使用RedisCloud作为我的Redis服务提供商.在本地,我可以使用Redis CLI检查我的Redis数据库,但是如何检查我的Heroku应用程序正在使用的RedisCloud数据库中的数据?

RedisCloud提供了一个显示统计信息的仪表板,但不显示实际数据.此外,我尝试使用Redis桌面管理器软件,但它有太多的错误,允许我远程连接到我的RedisCloud数据库.

ruby heroku redis

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