首页 \ 问答 \ iPhone - 在Facebook登录后,UISwitch的状态未设置为“On” - (void)fbDidLogin方法(iPhone - After facebook login, status of UISwitch is not setting to 'On' in -(void)fbDidLogin method)

iPhone - 在Facebook登录后,UISwitch的状态未设置为“On” - (void)fbDidLogin方法(iPhone - After facebook login, status of UISwitch is not setting to 'On' in -(void)fbDidLogin method)

我实施了Facebook登录并检查我的访问令牌的状态

-(void)fbDidLogin

现在,我有一个UITableView ,其中有一个切换Button作为UISwitch ,如果我有访问令牌,它将打开。 问题是,当我获得访问令牌时

-(void)fbDidLogin 

方法被调用。 在这里,我通过调用来设置切换按钮的开关

[self.switch setOn:YES animated:YES];

但没有发生。 当我返回并再次打开该页面时,它显示正确的状态,但不是当我将其设置在fbDidLogin 。 任何猜测为什么会发生这种情况?

对于Facebook身份验证,它会在应用程序之外返回,也许这就是为什么它会发生? 但我打电话来自fbDidLogin的Web fbDidLogin和它的工作正常。

代码很简单

- (void)fbDidLogin {    
    [self.switch setOn:YES animated:YES];    
}

I have implemented Facebook login and checking the status of my access token in

-(void)fbDidLogin

Now, I have a UITableView where I have a toggle Button as UISwitch which turns on if I have got an access token. The problem is, when I get an access token

-(void)fbDidLogin 

method gets called. Here, I'm setting the switch of toggle button on by calling

[self.switch setOn:YES animated:YES];

but its not happening. when I go back and open that page again, its showing the right status but not when I set it in fbDidLogin. Any guesses why this is happening?

For facebook authentication, it goes outside of the application and comes back, maybe thats why its happening? but I'm calling a webservice from fbDidLogin and its working fine.

code is simple

- (void)fbDidLogin {    
    [self.switch setOn:YES animated:YES];    
}

原文:https://stackoverflow.com/questions/10684330
更新时间:2023-08-12 18:08

最满意答案

这是更短,100倍以上的可读性。

编辑 Wug编辑了MarkJ的原始答案中的代码,代码如下:

If (item Is Nothing)
    Then Exit Sub ' we got a non-element
ElseIf (lastSelected Is Nothing) Then
    Set lastSelected = item ' we got our first go 
ElseIf (item = lastSelected) Then
    Exit Sub ' we already had what we got
End If
Set lastSelected = item ' we got something new 

这里是MarkJ的回复。 一个嵌套,如果只有一个Set。 看起来很整洁。

If (item Is Nothing) Then 
  Exit Sub ' we got a non-element 
ElseIf Not (lastSelected Is Nothing) Then ' not our first go
  If (item = lastSelected) Then 
    Exit Sub ' we already had what we got 
  End If 
End If
Set lastSelected = item ' we got something new
' does stuff here? @Wug is that true?
  • 要比较VB6中的引用相等性,使用项目是LastSelected。 因为item = lastSelected可能会评估对象中的默认属性,并对它们进行比较!
  • 由于简洁似乎是一个目标,请考虑这一点。 如果您在条件X为True时退出Sub,则不需要稍后再检查X. 这是假的! 除非它在评估之间改变它的值(例如X是一个检查系统时钟的函数)。 您正在检查项目是否是lastSelected,然后是否不是。 如果项目没有什么是假的,不要麻烦检查项目是不是什么是真的!
  • VB6不会与古代版本的Basic向后兼容
  • 不要担心VB6不是其他语言,而放松!

This is shorter and 100x more readable.

EDIT Wug edited the code in MarkJ's original answer, into this:

If (item Is Nothing)
    Then Exit Sub ' we got a non-element
ElseIf (lastSelected Is Nothing) Then
    Set lastSelected = item ' we got our first go 
ElseIf (item = lastSelected) Then
    Exit Sub ' we already had what we got
End If
Set lastSelected = item ' we got something new 

Here's MarkJ's edit in response. One nested if, but only one Set. Seems neater to me.

If (item Is Nothing) Then 
  Exit Sub ' we got a non-element 
ElseIf Not (lastSelected Is Nothing) Then ' not our first go
  If (item = lastSelected) Then 
    Exit Sub ' we already had what we got 
  End If 
End If
Set lastSelected = item ' we got something new
' does stuff here? @Wug is that true?
  • To compare reference equality in VB6 use item Is LastSelected. Because item = lastSelected will probably evaluate the default properties in the objects and compare those instead!
  • Since brevity appears to be a goal, consider this. If you Exit Sub when condition X is True, you don't need to check X again later. It is False! Unless it changes its value in between evaluations (e.g. X is a function that checks the system clock). You were checking whether item was lastSelected, then whether it wasn't. And if item Is Nothing is False, do not bother to check whether item Is Not Nothing is True!
  • VB6 does not short circuit for backwards compatibility with ancient versions of Basic
  • Stop worrying that VB6 is not some other language and relax!

相关问答

更多
  • 这是更短,100倍以上的可读性。 编辑 Wug编辑了MarkJ的原始答案中的代码,代码如下: If (item Is Nothing) Then Exit Sub ' we got a non-element ElseIf (lastSelected Is Nothing) Then Set lastSelected = item ' we got our first go ElseIf (item = lastSelected) Then Exit Sub ' we alread ...
  • 我能够在Notepad ++中使用“在所有打开文件中查找”,它具有VB6的格式化模式。 I was able to get "Find in All Open Files" working in Notepad++, which has a formatting mode for VB6.
  • 难怪你是'AngryHacker'。 我相信那是2001年10月。 No wonder you're the 'AngryHacker'. I believe that was Oct 2001.
  • 在以前的生活中,我参与了同一类型的项目。 原始应用程序是使用Access编写的框架。 然后出现了VB6,它似乎工作得很好,允许更多的功能,而不必改变Access中最初编写的内容。 来了.Net ...... ...尽管我不喜欢.Net的开发阶段,并且被迫使用互操作性层,但这是必要的。 也就是说,我会尽可能主观地回答这个问题: 如果您知道应用程序要完全转换为.Net,那么尽可能多地使用.Net进行新的开发。 除了关于互操作性的看法(和真理)之外,我没有理由把它推迟 - 例如更多的开销,性能等。 侧栏 - 至少 ...
  • 我不确定你到底想做什么。 要反转控制 ,只需在类中创建回调函数。 然后使用类(对象)的实例进行回调。 如果需要在运行时在不同的例程之间切换,请使用实现相同接口的单独类 - 策略模式 。 恕我直言地址太复杂,风险太大,无法以这种方式使用。 只有在需要使用Windows API 注册回调函数 时才应使用AddressOf 。 I'm not sure exactly what you're trying to do. To invert control, just create the callback fun ...
  • 如果你想要一个独立的表单,那么一个ActiveX EXE就足够了。 独立窗体是可以显示的窗体,调用应用程序将继续运行。 这两者不会阻止对方。 在这种情况下.NET DLL是矫枉过正的。 如果您需要涉及传统多任务的内容,比如获取大量数据并处理它,那么.NET DLL可能是一个更好的解决方案,因为多任务比EXE-> VB6的EXE解决方案更直接。 基于你的另一个问题,我觉得创建一个全局的多用途类,公开方法和参数来调用你的EXE所引用的ActiveX EXE中需要的表单,这将是一条可行的路。 更具体的将帮助我制定 ...
  • 就我所见,在VB6中没有办法别名。 如果您无法重命名该方法,这里可能是一个选项。制作一个简单包装printCommonString的方法呢? Public Sub pCS(ByRef CommonString() As Byte) printCommonString CommonString End Sub There is no way to alias in VB6 as far as I've ever seen. Here might be an option if you aren't a ...
  • 您可以为每一行构建一个字符串,当行字符串完成后,将其写入文件 例如使用帖子中的代码: Dim strLine As String Dim fso As New FileSystemObject Dim fsoStream As TextStream Set fsoStream = fso.CreateTextFile("C:\Users\Users\Desktop\File\Sample.csv", True) 'prepare the first row strLine = "Like This is ...
  • 您必须为WPF窗口提供一个COM接口(ActiveX用户控件),以暴露.tlb和.idl文件。 为此,我通常创建一个单独的项目,只关注此接口并引用您的WPF项目。 在那里添加一个或几个可以通过VB6程序实例化的类,并根据需要提供所有的GUID和接口描述。 通过这个项目,可以在项目的构建属性中使用'Register for COM Interop'选项,或者(我的首选项)在项目的构建事件脚本中使用regasm来创建.tlb和.idl。 您部署:您的WPF DLL,.tlb和.idl。 然后从VB6项目中引用此 ...
  • 怎么样: Dim I As Integer I = 32767 + 1 How about: Dim I As Integer I = 32767 + 1

相关文章

更多

最新问答

更多
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • 电脑高中毕业学习去哪里培训
  • 电脑系统专业就业状况如何啊?
  • IEnumerable linq表达式(IEnumerable linq expressions)
  • 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
  • Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
  • 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
  • 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
  • 的?(The ? marks in emacs/haskell and ghc mode)
  • 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • 悬停时的图像转换(Image transition on hover)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
  • java分布式框架有哪些
  • Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
  • PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
  • typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
  • 武陟会计培训类的学校哪个好点?
  • 从链接中删除文本修饰(Remove text decoration from links)