灯角

文章 0 评论 0 浏览 23

灯角 2024-10-17 03:45:50

第一个答案中的链接已损坏。这是此页面的网络存档的链接。

jQuery tablesorter 二次排序问题

我稍微修改了此代码以在 v.2.22.3 中工作(也许会在其他版本中工作)

从 tablesorter 的代码中剪切这些行:

if (c.sortForce !== null) {
    arry = c.sortForce;
    for (col = 0; col < arry.length; col++) {
        if (arry[col][0] !== indx) {
            c.sortList.push(arry[col]);
        }
    }
}

并将其粘贴到 c.sortList 之后。 Push([ indx, order ]); - 先前代码所在位置下方的一些行。
Tablesorter v.2.0 对变量有其他名称(例如 c => config、indx => i 等),但您可以找到搜索 sortForce 的正确位置 - 它在Tablesorter的代码

The link in first answer is broken. Here's a link to webarchive of this page.

jQuery tablesorter secondary sorting problem

I had slightly modified this code to work in v.2.22.3 (maybe will work in other versions)

Cut these lines from the tablesorter's code:

if (c.sortForce !== null) {
    arry = c.sortForce;
    for (col = 0; col < arry.length; col++) {
        if (arry[col][0] !== indx) {
            c.sortList.push(arry[col]);
        }
    }
}

And paste it after c.sortList.push([ indx, order ]); - some lines below the place with previous code.
Tablesorter v.2.0 had another names for variables (for c => config, indx => i, etc.) but you can find the right place searching for sortForce - it has several appearances in the code of Tablesorter

jQuery/Tablesorter:维护二级字母顺序排序

灯角 2024-10-17 02:12:50

这实际上取决于“数据”的含义。如果只是为了简单的请求,请尝试使用 AJAX。

That really depends on what you mean by "data". Try using AJAX if its just for simple requests.

JavaScript 中的 file_Get_contents

灯角 2024-10-16 13:45:33

在两台机器上尝试 var_dump ,它可能会说一些有趣的事情,“group”值似乎是一个对象,是什么类型的?它有一个 __sleep() 魔术方法吗?
确保您的测试机器和生产服务器具有相同的 php 版本,以便更好地理解问题。
@see http://www.php.net/manual/en/language .oop5.序列化.php

try var_dump instead in both machines, it may say something interesting, "group" value seems to be an object, of what type? does it have a __sleep() magic method?
ensure your test machine and production server has the same php version to better understand the issue.
@see http://www.php.net/manual/en/language.oop5.serialization.php

PHP_Incomplete_Class 对象 / print_r 的不同响应

灯角 2024-10-16 12:43:32

如果您想直接更新 Surfaces 像素,可以使用“Device.UpdateTexture”。这会将 Pool.SystemMemory 中创建的纹理更新为 Pool.Default 中创建的纹理。

但这听起来不像您想做的事情。使用效果来硬件加速。如果您想知道我如何向您展示。

If you are wanting to update a Surfaces pixels directly, you can use "Device.UpdateTexture". This updates a Texture created in Pool.SystemMemory to a Texture created in Pool.Default.

But this doesn't sound like what you want to be doing. Use an Effect to hardware accelerate this. If you would like to know how I can show you.

Direct3D 9 中表面的部分变暗

灯角 2024-10-16 03:26:21

至少部分问题(在更新的代码中)是在创建单元格之前不创建 UISwitch。当该表行进入和退出视图时,您的 codeSwitch ivar 最终可能会指向不同的开关。

我的做法如下:在 tableView:numberOfRowsInSection: 中,使用 NSUserDefaults 来查看表应处于哪个状态,而不是使用开关的状态(可能尚不存在)。然后,在开关的操作方法中,在插入或删除表行之前调用 setBool:forKey: 以获取用户默认值。

从本质上讲,这使得代码更好地遵循 MVC 模型,因为它将视图(UISwitch)与模型(用户默认值中的 BOOL)分开,并且 em>控制器(视图控制器)在中间。通过混淆视图和模型(开关和布尔状态),当视图尚不可用时尝试处理状态时,您最终会遇到问题。

顺便说一句,您根本不需要在表格视图上调用 setNeedsDisplay

At least part of your problem (in the updated code) is that you don't create the UISwitch until you create the cell. Your codeSwitch ivar may end up pointing to a different switch as that table row comes in and out of view.

Here's how I'd do this: in tableView:numberOfRowsInSection:, use the NSUserDefaults to see which state the table should be in, instead of using the state of the switch (which may not exist yet). Then, in the switch's action method, call setBool:forKey: for the user defaults before you insert or delete the table row.

In essence, this makes the code follow the MVC model better, because it separates your view (the UISwitch) from the model (the BOOL in user defaults), with the controller (the view controller) in the middle. By confounding the view and the model (the switch and the boolean state), you end up with problems when trying to deal with the state when the view isn't available yet.

BTW, you shouldn't need to call setNeedsDisplay on the table view at all.

将开关设置为“开”,重新加载表,然后插入新行

灯角 2024-10-16 01:54:44

:hover 已经在 IE7+ 中工作,IE6 只允许它与 元素一起使用...所以我想说你已经可以在没有库的情况下单独使用 CSS,只要 IE6 不是问题。

#menusearchbutton { background-position: 0px 0px; }
#menusearchbutton:hover { background-position: 0px -24px; }

:hover already works in IE7+, IE6 only allows it with a <a> elements...so I'd say you can already use CSS alone with no library, as long as IE6 isn't a concern.

#menusearchbutton { background-position: 0px 0px; }
#menusearchbutton:hover { background-position: 0px -24px; }

更改背景位置 - 使用 jQuery 或 :hover 与 Selectivizr 更好?

灯角 2024-10-16 01:24:54

HTML 应该是语义化的,并且应该首先考虑它 - 即它应该具有清晰的结构和含义,而无需了解 javascript 位于之上。就像

    应仅包含

  • 元素一样,
    应仅具有单一用途。使用 javascript 通过检索动态数据来增强表单很好,但是如果使用额外的 HTTP POST(修改服务器上的数据的类型),那么这实际上代表了第二个目的,因此应使用第二种形式。第二种形式具有自己的“action”属性,表示此处正在发生不同的行为,并且不仅在概念上更合理,而且在必要时更易于分析、调试或扩展。
<form id="bigform" action="bigform.php">
    <!-- Tabs here -->
</form>
<form id="newperson" action="newform.php">
   <input name="extra">
   <button type="submit" value="Add">
   <!-- Note also the use of <button> instead of <input> -->
</form>

重要的是您仍然可以在主窗体中实现所需的流程。在主窗体上,不要使用嵌套窗体,而是使用

。该字段集将充当新人表单的代理。这里的输入可以有一个 ID,但不应该有一个名称,因为它的值不应该与主表单一起提交。正如其他答案中已经提到的,按钮应该更改为“按钮”类型,而不是“提交”类型。

<form id="bigform" action="bigform.php">
    <!-- Tabs here -->
    <fieldset id="newpersonProxy">
        <input id="extra">
        <button type="button" value="Add">
    </fieldset>
</form>

现在通过 Javascript 不显眼地添加所需的行为,方法是:

  1. 隐藏第二个表单,#newperson
  2. 通过绑定到 #newpersonProxy 内任何输入的 keyup 事件以及按钮的 click 事件来响应“提交”。对于 keyup 事件,请使用 event.which 而不是 event.keyCode,因为 jQuery 对此进行了规范化。您需要 event.which == 13 作为回车键。
  3. 然后,在调用 $("#newperson").submit() 之前,将代理输入中的值复制到真实表单。

这有效地将序列化和发送数据的责任委托给第二种形式,允许将任何类型的逻辑附加到第二种形式,并与第一种形式解耦。

此外,由于首先考虑的是功能性 HTML,一个简单的调整就可以让表单在没有 Javascript 的情况下完美工作 - 只需使用 CSS 隐藏

,并使用 Javascript 显示它。如果关闭 Javascript,选项卡将分开,嵌套字段集将被隐藏,并且将显示第二个表单(并且功能齐全,只是不通过 AJAX)。

HTML should be semantic, and it should be considered first - i.e. it should have a clear structure and meaning without an understanding of what javascript lies on top. Like the way a <ul> should only contain <li> elements, a <form> should have only a single purpose. Using javascript to enhance a form by retrieving dynamic data is fine, but if an extra HTTP POST is used (the type that modifies data on the server), then this really represents a second purpose, and thus a second form should be used. A second form, with its own "action" attribute, signals that a distinct behaviour is happening here, and is not only more conceptually sound, but easier to analyse, debug or extend when necessary.

<form id="bigform" action="bigform.php">
    <!-- Tabs here -->
</form>
<form id="newperson" action="newform.php">
   <input name="extra">
   <button type="submit" value="Add">
   <!-- Note also the use of <button> instead of <input> -->
</form>

The important thing is that you can still achieve the desired flow within the main form. On your main form, instead of using a nested form, use a <fieldset>. This fieldset will behave as a proxy for the newperson form. The input inside here can have an ID, but should not have a name since its value is not meant to be submitted with the main form. As already mentioned in other answers, the button should be changed to a type of "button" and not "submit".

<form id="bigform" action="bigform.php">
    <!-- Tabs here -->
    <fieldset id="newpersonProxy">
        <input id="extra">
        <button type="button" value="Add">
    </fieldset>
</form>

Now add the desired behaviour unobtrusively through Javascript, by:

  1. Hiding the second form, #newperson.
  2. Responding to "submits" by binding to the keyup event of any input within #newpersonProxy, as well as to the click event of the button. For the keyup event, use event.which instead of event.keyCode as jQuery normalises this. You want event.which == 13 for the enter key.
  3. Then copying the value from the proxy inputs over to the real form, before calling $("#newperson").submit().

This is effectively delegating the responsibility of serializing and sending the data to the second form, allowing any sort of logic to be attached to the second form, and be de-coupled from the first.

Further, as functioning HTML was considered first, a simple tweak can allow the forms to work perfectly without Javascript - just hide the <fieldset> using CSS, and show it with Javascript. If Javascript is turned off, the tabs will break apart, the nested fieldset will be hidden, and the second form will be displayed (and fully functioning, just not via AJAX).

在选项卡式表单中间添加额外(嵌套)表单的最佳方法

灯角 2024-10-16 00:38:01

确保您正在编辑您认为正在编辑的配置文件。看一下下面的代码

#File: app/code/core/Mage/Core/Model/Config.php

public function loadBase()
{
    $etcDir = $this->getOptions()->getEtcDir();
    $files = glob($etcDir.DS.'*.xml');
    $this->loadFile(current($files));
    while ($file = next($files)) {
        $merge = clone $this->_prototype;
        $merge->loadFile($file);
        $this->extend($merge);
    }
    if (in_array($etcDir.DS.'local.xml', $files)) {
        $this->_isLocalConfigLoaded = true;
    }
    return $this;
}

这是将 local.xml 文件合并到配置树的代码。添加一些调试代码

public function loadBase()
{
    var_dump('Called ' . __METHOD__);   //ensure we're being called    
    $etcDir = $this->getOptions()->getEtcDir();
    $files = glob($etcDir.DS.'*.xml');
    $this->loadFile(current($files));
    while ($file = next($files)) {
        var_dump($file);                    //dump the file path being loaded to the browser
        $merge = clone $this->_prototype;
        $merge->loadFile($file);
        $this->extend($merge);
    }
    if (in_array($etcDir.DS.'local.xml', $files)) {
        $this->_isLocalConfigLoaded = true;
    }
    exit;                                   //bail out early
    return $this;
}

在浏览器中加载您的站点,并观察通过 var_dump 输出的路径。确保正在加载的文件是您认为正在加载的文件。请记住,它看起来像是 etc 文件夹中的每个 XML 文件都已加载并合并。

如果路径符合您的预期,接下来添加一些调试代码以输出 XML 文件的内容) 正在加载。

public function loadBase()
{
    var_dump('Called ' . __METHOD__ . '');  //ensure we're being called    
    $etcDir = $this->getOptions()->getEtcDir();
    $files = glob($etcDir.DS.'*.xml');
    $this->loadFile(current($files));
    while ($file = next($files)) {
        header('Content-Type: text/plain'); //so the browser renders it as plain text
        echo file_get_contents($file);      //dump the contents of the file being loaded to the browser
        $merge = clone $this->_prototype;
        $merge->loadFile($file);
        $this->extend($merge);
    }
    if (in_array($etcDir.DS.'local.xml', $files)) {
        $this->_isLocalConfigLoaded = true;
    }
    exit;                                   //bail out early
    return $this;
}

如果这些文件中的数据库信息是正确的,那么您的系统已经被定制和/或以某种方式被黑客攻击,有代码调用另一个数据库服务器。

如果是这种情况,您需要安装 xDebug 之类的东西才能获得一些不错的错误报告。这将使您找到引发错误的确切代码,此时您可以追溯到它获取连接信息的位置。

祝你好运。

Make sure you're editing the config file you think you're editing. Take a look at the following code

#File: app/code/core/Mage/Core/Model/Config.php

public function loadBase()
{
    $etcDir = $this->getOptions()->getEtcDir();
    $files = glob($etcDir.DS.'*.xml');
    $this->loadFile(current($files));
    while ($file = next($files)) {
        $merge = clone $this->_prototype;
        $merge->loadFile($file);
        $this->extend($merge);
    }
    if (in_array($etcDir.DS.'local.xml', $files)) {
        $this->_isLocalConfigLoaded = true;
    }
    return $this;
}

This is the code that merges in your local.xml file to the configuration tree. Add some debugging code

public function loadBase()
{
    var_dump('Called ' . __METHOD__);   //ensure we're being called    
    $etcDir = $this->getOptions()->getEtcDir();
    $files = glob($etcDir.DS.'*.xml');
    $this->loadFile(current($files));
    while ($file = next($files)) {
        var_dump($file);                    //dump the file path being loaded to the browser
        $merge = clone $this->_prototype;
        $merge->loadFile($file);
        $this->extend($merge);
    }
    if (in_array($etcDir.DS.'local.xml', $files)) {
        $this->_isLocalConfigLoaded = true;
    }
    exit;                                   //bail out early
    return $this;
}

Load your site in a browser, and observe the paths being output via var_dump. Make sure that the file(s) being loaded are the ones you think are being loaded. Keep in mind that it looks like every XML file from the etc folder is loaded and merged in.

If the paths are what you expect, next add some debugging code to output the contents of the XML file(s) being loaded.

public function loadBase()
{
    var_dump('Called ' . __METHOD__ . '');  //ensure we're being called    
    $etcDir = $this->getOptions()->getEtcDir();
    $files = glob($etcDir.DS.'*.xml');
    $this->loadFile(current($files));
    while ($file = next($files)) {
        header('Content-Type: text/plain'); //so the browser renders it as plain text
        echo file_get_contents($file);      //dump the contents of the file being loaded to the browser
        $merge = clone $this->_prototype;
        $merge->loadFile($file);
        $this->extend($merge);
    }
    if (in_array($etcDir.DS.'local.xml', $files)) {
        $this->_isLocalConfigLoaded = true;
    }
    exit;                                   //bail out early
    return $this;
}

If the database information is correct in these files, then your system has been customized and/or hacked in some way that there's code calling out to another database server.

If that's the case you'll need to install something like xDebug to get some decent error reporting. This will let you find the exact code that's throwing the error, at which point you can trace it back to where it's getting it's connection information.

Good luck.

Magento 实例指向错误的数据库

灯角 2024-10-15 20:12:05

除非我弄错了,否则你只会遇到第三个查询的问题;前两个查询运行良好。对于第三个查询(总结最后两条记录的成本),您可以按降序对结果集进行排序,并将其限制为两条记录。

Unless I got you wrong, you only have problems with the third query; the first two queries are working well. For the third query (summing up the costs of the last two records), you could sort the result set in descending order and limit it to two records.

Mysql 查询使用 SUM 和 Limit 计算使用量和成本

灯角 2024-10-15 19:52:13

get_ip() 是如何工作的?

如果 nginx 是反向代理,gunicorn 是应用程序服务器,则它始终从本地计算机上的 nginx 获取请求。

在我的例子中,nginx 发送到应用程序服务器的真实 IP 是通过 nginx conf 行 HTTP_X_REAL_IP proxy_set_header X-Real-IP $remote_addr;

所以你可能想要设置它,并在您的 django 应用帐户中使用新的 IP 标头或设置 request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']

How does get_ip() work?

If nginx is a reverse proxy and gunicorn is the app server, it's always getting requests from nginx on the local machine.

The real ip that nginx sends to the app server is in my case HTTP_X_REAL_IP via the nginx conf line proxy_set_header X-Real-IP $remote_addr;

So you might want to set that, and in your django app account for the different header by either using your new IP header or set request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']

Django获取IP仅返回127.0.0.1

灯角 2024-10-15 18:38:47

正如 Jim 所说,UIKit 元素的源代码不可用,因为它不是开源的。
但是,如果您正在搜索显示如何使用它们的源代码,您可以在 开发者网站
UICatalog源代码就是您要找的。
它展示了如何使用最常见的 UIKit 元素,如按钮、选择器、警报和其他......

As Jim said, the source code ad an UIKit element is not available because it isn't open source.
But if you are searching for source code that show how to use them, you can search on the Developer Site.
UICatalog source code is what are you looking for.
It shows how to use the most common UIKit's element, like buttons, pickers, alerts and other...

ios4的UIDatePicker源码在哪里可以找到

灯角 2024-10-15 18:37:24

如果您确实不喜欢 Boost asio,那么您可能会喜欢 dlib 中的套接字支持。它更简单,因为它使用传统的阻塞 IO 和线程,而不是 asio 的异步前摄器模式。例如,它可以轻松创建一个从 iostream 读取和写入的线程 TCP 服务器。例如,请参阅此示例。或者,如果不充当服务器,您可以制作一个简单的 iosockstream

If you really don't like Boost asio then you might like the sockets support in dlib. It is simpler in the sense that it uses traditional blocking IO and threads rather than asio's asynchronous proactor pattern. For example, it makes it easy to make a threaded TCP server that reads and writes from the iostreams. See this example for instance. Or you can just make a simple iosockstream if not acting as a server.

便携式轻型 C++套接字包装器

灯角 2024-10-15 15:39:15

XAML 页面无法显示在浏览器窗口中。 Silverlight 实际上所做的就是在 << 中显示 Silverlight 程序。对象> aspx(或html)页面中的标记;而已。

在您的 silverlight 项目中,如果您选择在新网站中托管您的项目,您将看到第二个项目,其中包含 htm 和 aspx 文件,该文件托管链接到您的 xap 文件的对象。

因此基本上,您需要创建第二个 Silverlight 项目,该项目将托管在不同的 aspx 页面中。然后,在您的主 silverlight 项目中,您可以在新的 Web 浏览器窗口中打开该新的 aspx 页面。

a XAML page cannot be shown in a browser window. What Silverlight do actually is showing the Silverlight program within an < object > tag in the aspx (or html) page; nothing more.

In your silverlight project, if you chose to host your project in a new web site, you will see a second project with both a htm and aspx file that hosts that object that links to your xap file.

So basically, you need to create a second Silverlight project that will be hosted in a different aspx page. Then in your main silverlight project your can open that new aspx page in a new web browser window.

silverlight - 在新的网络浏览器中打开 xaml

灯角 2024-10-15 13:38:26

您确实需要提供广告,这是由苹果服务选择的。

You do need provide ad, it is chosen by apple service.

在iPhone和iPad SDK中使用iAds时,我们是否必须提供广告?

灯角 2024-10-15 13:06:24

在深入研究代码并进行操作之后,我找到了一种方法来做到这一点,无论您在哪里获得框架,该方法都可能记录在案。

查看 iCodeOauthViewController.m,在 viewDidAppear: 内部,您可以在引擎上调用 isAuthorized,它会告诉您是否已通过身份验证。如果返回 yes,您可以调用引擎对象上的 clearAccessToken 方法来清除该身份验证。当接下来调用 controllerToEnterCredentialsWithTwitterEngine: delegate: 时,它将返回视图控制器以重新输入用户名和密码。

编辑:
在 iCodeOauthViewController.m 内的 fo viewDidAppear: (line 46) 中,您将看到这一行:

UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];

如果用户尚未登录,此调用将返回您看到的登录屏幕。如果用户已登录,则返回 nil。如果控制器为零,则直接跳转到列表。

要“注销”用户,您可以使用此方法:

- (void)switchUser
{
    // log off the existing user if one is validated
    if ([_engine isAuthorized])
        [_engine clearAccessToken];

    // display the login prompt
    UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];       
    if (controller) 
        [self presentModalViewController: controller animated: YES];
}

编辑2:
看来您的问题出在您的 tweet 方法内部。您已在推文尝试发送后添加了警报代码,如果用户未登录,这会导致崩溃。这是您的代码:

-(IBAction)tweet:(id)sender {

    [textfield resignFirstResponder];
    [_engine sendUpdate:[textfield text]];
    [self updateStream:nil];


    if([_engine isAuthorized]==NO){UIAlertView *alert = [[UIAlertView alloc]
                                                         initWithTitle: @"Please, Sign in"
                                                         message: @"You'll have to sign in for this app to work!"
                                                         delegate: nil
                                                         cancelButtonTitle:@"Ok"
                                                         otherButtonTitles:nil];
        [alert show];
        [alert release];
        }
}

将其更改为如下所示:

-(IBAction)tweet:(id)sender {


if([_engine isAuthorized]==NO){
    UIAlertView *alert = [[UIAlertView alloc]
                                                     initWithTitle: @"Please, Sign in"
                                                     message: @"You'll have to sign in for this app to work!"
                                                     delegate: nil
                                                     cancelButtonTitle:@"Ok"
                                                     otherButtonTitles:nil];
    [alert show];
    [alert release];
    }
else {
    [textfield resignFirstResponder];
    [_engine sendUpdate:[textfield text]];
    [self updateStream:nil];

}

}

请注意,我们现在检查是否我们在尝试发送推文之前经过身份验证,如果我们未获得授权,则会弹出警报。抱歉,我可能在发布警报的事情上误导了您,我误解了您的意思。

我建议尝试更多地了解 Objective-C 的工作原理并获取 熟悉调试器。如果您运行调试器并且您的应用程序崩溃,调试器将在崩溃的代码中停止,您可以查看堆栈中的函数调用以确定代码做错了什么。请参阅此堆栈溢出问题(具体是答案),了解有关如何更好地开始使用 Objective-C。我会推荐一些在线网站,例如 CocoaDevCentral 教程。 记住这一点。您已经有了一个良好的开端,尝试根据示例制作自己的东西。如果一个想法不能立即在你的主项目中实现,不要害怕做一个副项目来尝试它,即使它像找出另一种方法来完成 2 + 2 一样简单。希望这会有所帮助。

After digging into the code and playing with things I found a way to do this that is probably documented wherever you got the framework.

Looking at iCodeOauthViewController.m, inside of viewDidAppear: you can call isAuthorized on the engine and it will tell you if you are authenticated or not. If this returns yes, you can then call the clearAccessToken method on the engine object to clear that authentication. When controllerToEnterCredentialsWithTwitterEngine: delegate: is next called it will return the view controller for re-entering the user name and password.

edit:
in iCodeOauthViewController.m inside fo viewDidAppear: (line 46) you will see this line:

UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];

this call returns the login screen that you see if the user is not yet logged in. If the user is logged in, it returns nil. If the controller is nil it jumps directly to the list.

to "log out" a user you could use this method:

- (void)switchUser
{
    // log off the existing user if one is validated
    if ([_engine isAuthorized])
        [_engine clearAccessToken];

    // display the login prompt
    UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];       
    if (controller) 
        [self presentModalViewController: controller animated: YES];
}

edit 2:
Looks like your problem is inside of your tweet method. You have added the alert code after the tweet attempts to send, and that results in a crash if the user isn't logged in. Here is your code:

-(IBAction)tweet:(id)sender {

    [textfield resignFirstResponder];
    [_engine sendUpdate:[textfield text]];
    [self updateStream:nil];


    if([_engine isAuthorized]==NO){UIAlertView *alert = [[UIAlertView alloc]
                                                         initWithTitle: @"Please, Sign in"
                                                         message: @"You'll have to sign in for this app to work!"
                                                         delegate: nil
                                                         cancelButtonTitle:@"Ok"
                                                         otherButtonTitles:nil];
        [alert show];
        [alert release];
        }
}

change it to look like this:

-(IBAction)tweet:(id)sender {


if([_engine isAuthorized]==NO){
    UIAlertView *alert = [[UIAlertView alloc]
                                                     initWithTitle: @"Please, Sign in"
                                                     message: @"You'll have to sign in for this app to work!"
                                                     delegate: nil
                                                     cancelButtonTitle:@"Ok"
                                                     otherButtonTitles:nil];
    [alert show];
    [alert release];
    }
else {
    [textfield resignFirstResponder];
    [_engine sendUpdate:[textfield text]];
    [self updateStream:nil];

}

}

Notice that we now check to see if we are authenticated before trying to send the tweet, and if we are not authorized then pop up an alert instead. My apologies, I may have misled you with the releasing the alert thing, I misunderstood what you were saying.

I would recommend trying to understand a little more about how objective-c works and get familiar with the debugger. If you run the debugger and your app is crashing, the debugger will stop at the point in the code that is crashing, and you can look through the function calls in the stack to determine what the code is doing wrong. See this stack overflow question (specifically the answers) for more resources on how to get a better start with objective-c. I would recommend some of the online sites like CocoaDevCentral's tutorials. Remember this. You're off to a good start trying to make something your own based on an example. Don't be afraid to make a side project to play around with an idea if it's not immediately working out in your main project, even if it's something as simple as figuring out another way to do 2 + 2. Hope that helps.

oAuth/MGTwitterEngine 更改 iPhone 的用户?

更多

推荐作者

巷子口的你

文章 0 评论 0

微信用户

文章 0 评论 0

神妖

文章 0 评论 0

7460852697

文章 0 评论 0

ligengkai

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文